c程序彩色输出导致aes加解密失败

今天遇到了一个很奇怪的问题,在aes解密函数前调用了一个彩色输出打印的函数,结果解密失败。

彩色输出函数如下:

string red(const string str){
        return "\033[31m"+str+"\033[0m";
}
string yellow(const string str){
        return "\033[33m"+str+"\033[0m";
}


后来,查文档发现如下说明:

EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex() are the corresponding decryption operations. EVP_DecryptFinal() will return an error code if padding is enabled and the final block is not correctly formatted. The parameters and restrictions are identical to the encryption operations except that if padding is enabled the decrypted data buffer outpassed to EVP_DecryptUpdate() should have sufficient room for (inl + cipher_block_size) bytes unless the cipher block size is 1 in which case inl bytes is sufficient.


所以,我觉得可能是可能是调用彩色打印函数,导致溢出了?

总之,去掉就不会解密失败了,奇怪,求解释!

你可能感兴趣的:(彩色、输出、加密、解密、aes)