If u plan to use some sort of "key" to encrypt ur password then there is an
way to do that!
just check this code..


const int MAX_PHRASE_LENGTH=250;

string EncryptString(const char *plaintext, const char *passPhrase);

string DecryptString(const char *ciphertext, const char *passPhrase);

int main()

{

char passPhrase[MAX_PHRASE_LENGTH]= "this is key"", plaintext[1024];


plaintext = "this is the password";

cout << "\nPlaintext: ";

string ciphertext = EncryptString(plaintext, passPhrase);

cout << "\nCiphertext: " << ciphertext << endl;


string decrypted = DecryptString(ciphertext.c_str(), passPhrase);

cout << "\nDecrypted: " << decrypted << endl;

return(0);

}

string EncryptString(const char *instr, const char *passPhrase)

{

string outstr;

DefaultEncryptorWithMAC encryptor(passPhrase, new HexEncoder(new
StringSink(outstr)));

encryptor.Put((byte *)instr, strlen(instr));

encryptor.MessageEnd();

return outstr;

}

string DecryptString(const char *instr, const char *passPhrase)

{

string outstr;

HexDecoder decryptor(new DefaultDecryptorWithMAC(passPhrase, new
StringSink(outstr)));

decryptor.Put((byte *)instr, strlen(instr));

decryptor.MessageEnd();

return outstr;

}



U can find it in the test.cpp..

nandu

Reply via email to