我正在执行以下过程来加密:
EVP_CIPHER_CTX * ctx;
if (! (ctx = EVP_CIPHER_CTX_new ()))
handleErrors ();
if (1! = EVP_EncryptInit_ex (ctx, EVP_aes_128_cbc (), NULL, key, InitializationVector))
handleErrors ();
if (1! = EVP_EncryptUpdate (ctx, new Encryption, & len, unencryptedtext, strlen (unencryptedtext)))
handleErrors ();
ciphertext_len = len;
if (1! = EVP_EncryptFinal_ex (ctx, newCryption + len, & len))
handleErrors ();
ciphertext_len + = len;
/ * Clean up * /
EVP_CIPHER_CTX_free (ctx);
执行后,我得到两件事,加密字符串 (newCipher) 和该字符串的长度 (ciphertext_len)。
这是一个预览版本,从各种来源合并,因为名字难看,而且它们遵循不同的格式......
好吧,问题是当我想获得加密的十六进制字符串时,我会执行以下操作:
BIO_dump_fp (stdout, newCipher, ciphertext_len);
获得输出:** 0000 - 12 b0 76 00 74 78 fc 61-09 70 c4 9e 8d f8 d8 47 ..v.tx.ap ..... G **
如果我这样做:
int i;
for (i = 0; i <ciphertext_len; i ++) {
printf ("% x", newCipher [i]);
}
出现:** 12 ffffffb0 76 0 74 78 fffffffc 61 9 70 ffffffc4 ffffff9e ffffff8d fffffff8 ffffffd8 47 **
突然 6 'f' 出现在一些八位位组之前,但没有出现在其他八位位组之前。
问题 如何删除那些'f'并输出我真正想要的十六进制字符串:** 12b076007478fc610970c49e8df8d847 ** 或者我可以遵循哪些其他方法来获得它?