|
Bored again. Need help with a utility? Joint efforts preferred. School exam/tests projects NOT. Windows win32 (VS 2005) enviroment preferred. MFC NOT. Math stuff is cool. Looking for an ongoing public(here) project where we all pitch in.
Actually school stuff is ok if it has a public benefit (non-profit). No web stuff. I have 1000? funtions/classes in my personal lib that I'm willing to share/use. Would just like to have fun coding a public project (here).
-Gord.
|
|
|
Here’s a simple file encrypter-decrypter.
Run once to encrypt, once again to decrypt.
Written with Visual Studio 2005, Win32 console application.
//////////////////////////////////////////////////////////////////////
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <tchar.h>
//////////////////////////////////////////////////////////////////////
// stdafx.cpp : source file that includes just the standard includes
// EncryptFile.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////
// EncryptFile.cpp : Defines the entry point for the console application.
// A simple 1 byte encrypter/ decrypter.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
FILE *stream;
unsigned char data,key;
char user_input[80];;
errno_t error = 1; // 0 = OK
long file_pos;
key = 135;
memset(user_input,0,80);
cout << "Enter file name to encrypt...";
cin >> user_input;
if( (error = fopen_s( &stream,"/forum/ctemptest.txt", "r+b" )) !=0 )
{ printf( "The file 'crt_fopen_s.c' was not opened\n" );
cout << "Press any get" << endl;
cin >> user_input;
return 0;
}
cout << "wait...";
//run once to encrypt, once again to decrypt.
file_pos = 0;
while(1)
{
fseek(stream,file_pos,SEEK_SET);
if(!fread(&data,1,1,stream)) break;
data = data ^ key;
fseek(stream,file_pos,SEEK_SET);
fwrite(&data,1,1,stream);
file_pos++;
}
cout << "File encrypted. Press any key";
_getch();
fclose(stream);
}
//////////////////////////////////////////////////////////////////////
|
|
|
Oops, the line
printf( "The file 'crt_fopen_s.c' was not opened\n" );
should be
printf( "The file <%s> was not opened.\r\n", input );
<Added>
printf( "The file <%s> was not opened.\r\n",user_input );
That's it, it's official, I have CRT dyslexia lol.
<Added>
I'm thinking about unarchiving my doom2 code. I had been working on a win-doom port of it which has better graphic resolution and runs in 16 or 24 bit color. If anyone is interested, I'll give you my source code.
The dos version was written with 'Rhide' and the windows version with Visual c++ 5. I would like to convert the maps to polys and use direct x instead of code-rendering.Probably redone ground up. Just an idea.
-Gord.
|
|
|
|
|
|
|
|