static String strutil_decrypt_tf(const String &original) { if(! strutil_has_twofish) { ERRORMESSAGE((_("Strong encryption algorithm not available."))); return wxEmptyString; } if ( !setup_twofish() ) { ERRORMESSAGE((_("Impossible to use encryption without password."))); } CryptData input; input.FromHex(original.c_str()+1); // skip initial '-' CryptData output; int rc = TwoFishCrypt(0, 128, gs_GlobalPassword.utf8_str(), &input,&output); if(rc) { return output.data; } return wxEmptyString; }
/* * All encrypted data is hex numbers. To distinguish between strong * and weak data, we prefix the strong encryption with a '-'. */ static String strutil_encrypt_tf(const String &original) { if ( setup_twofish() ) { CryptData input(original.utf8_str()); CryptData output; int rc = TwoFishCrypt(1, 128, gs_GlobalPassword.utf8_str(), &input ,&output); if(rc) { String tmp = output.ToHex(); String tmp2; tmp2 << '-' << tmp; return tmp2; } } else { ERRORMESSAGE((_("Impossible to use encryption without password."))); } return wxEmptyString; }
//client -> us void OSIEncryption::DecryptFromClient( const BYTE *in, BYTE *out, int len ) { TwoFishCrypt( in, out, len ); }
//us -> server void OSIEncryption::EncryptForServer( const BYTE *in, BYTE *out, int len ) { TwoFishCrypt( in, out, len ); }