Something really simple I just made out of sheer boredom and slight interest. Idc what you do with it.
[php]#pragma once
class cCrypt
{
public:
static char* encrypt(char* key, char* bytes, int size);
static char* decrypt(char* key, char* bytes, int size);
};[/php][php]#include "stdafx.h"
#include "cCrypt.h"
#include <windows.h>
char* cCrypt::encrypt(char* key, char* bytes, int size) {
char* returnValue = new char[200];
ZeroMemory(returnValue, 200);
int iKeyLen = strlen(key);
int iKeyIndex = 0;
for(int i = 0; i < size; i++) {
if(iKeyIndex > strlen(key))
iKeyIndex = 0;
returnValue[i] = bytes[i] + key[iKeyIndex];
iKeyIndex++;
}
return returnValue;
}
char* cCrypt::decrypt(char* key, char* bytes, int size) {
char* returnValue = new char[200];
ZeroMemory(returnValue, 200);
unsigned int iKeyLen = strlen(key);
int iKeyIndex = 0;
for(int i = 0; i < size; i++) {
if(iKeyIndex > strlen(key))
iKeyIndex = 0;
returnValue[i] = bytes[i] - key[iKeyIndex];
iKeyIndex++;
}
return returnValue;
}[/php]
Example :[php]
#include "stdafx.h"
#include "cCrypt.h"
int main(int argc, _TCHAR* argv[])
{
char* hello = "Hello";
char* encryptedMessage = cCrypt::encrypt("nig", hello, strlen(hello));
printf("Encrypted:%sn", encryptedMessage);
printf("Decrypted:%sn", cCrypt::decrypt("nig", encryptedMessage, strlen(encryptedMessage)));
delete encryptedMessage;
return 0;
}
[/php]