int decryptString(char* result, char* password) { HCkCrypt2 crypt; BOOL success; const char * hexKey; const char * text = result; const char * encText; const char * decryptedText; crypt = CkCrypt2_Create(); success = CkCrypt2_UnlockComponent(crypt,"Anything for 30-day trial"); if (success != TRUE) { printf("Crypt component unlock failed\n"); return 0; } CkCrypt2_putCryptAlgorithm(crypt,"aes"); CkCrypt2_putCipherMode(crypt,"cbc"); CkCrypt2_putKeyLength(crypt,256); // Generate a binary secret key from a password string // of any length. For 128-bit encryption, GenEncodedSecretKey // generates the MD5 hash of the password and returns it // in the encoded form requested. The 2nd param can be // "hex", "base64", "url", "quoted-printable", etc. hexKey = CkCrypt2_genEncodedSecretKey(crypt,password,"hex"); CkCrypt2_SetEncodedKey(crypt,hexKey,"hex"); CkCrypt2_putEncodingMode(crypt,"base64"); // Encrypt a string and return the binary encrypted data // in a base-64 encoded string. decryptedText = CkCrypt2_decryptStringENC(crypt,result); //printf("%s\n",encText); char tmpStr[1000]; strcpy(result, decryptedText); CkCrypt2_Dispose(crypt); }
EXTAPI const char* secure_aes_cbc_decrypt(const char *cipherText64) { plainText = CkCrypt2_decryptStringENC(crypt, cipherText64); return plainText; }