Hi,

I managed to get a string encrypted with no errors using Twofish, working from the example in the FAQ:

string stringToEncode = "This is a secret!";
byte key[Twofish::DEFAULT_KEYLENGTH] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
byte iv[Twofish::BLOCKSIZE] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
string cipher;
StringSink* sink = new StringSink(cipher);
Base64Encoder* base64_enc = new Base64Encoder(sink);
CBC_Mode<Twofish>::Encryption twofish(key, Twofish::DEFAULT_KEYLENGTH, iv);
StreamTransformationFilter* twofish_enc = new StreamTransformationFilter(twofish, base64_enc);
StringSource source(stringToEncode, true, twofish_enc);


However, I am not clear how I would go about reversing the process in order to decrypt the encoded string. Is there anyone who could help me? Right now I'm not sure exactly what's going on in the above code, but a decrypt version of this might help make things clearer for me.

The encoded string is going to be passed in a URL to a PHP script, so a better understanding of what is going on in the decrypt routine here will help me when the time comes to get a decrypt routine working in PHP...

Any help would be greatly appreciated, and if you feel that the code above should be different given my purpose (sending in a URL to PHP), please let me know. This is all new (and confusing) to me.

CN



Reply via email to