strlen(key_str)=13, sizeof(key_str)=4 These three items indicate that your key_str and key_string are exactly the same.
I suspect this is the problem here AES_set_encrypt_key(key_string, 256, &key); Because your key is only 13 bytes long, even 13*8 is only 104 bits, so the 256 you passed is probably accessed out of bounds. Determined data It is because of this uncertain data that the keys are different during encryption and decryption, so the decryption is garbled.
strcmp(key_string, key_str) returns 0;
strlen(key_string)=13, sizeof(key_string)=4
strlen(key_str)=13, sizeof(key_str)=4
These three items indicate that your key_str and key_string are exactly the same.
I suspect this is the problem here
AES_set_encrypt_key(key_string, 256, &key);
Because your key is only 13 bytes long, even 13*8 is only 104 bits, so the 256 you passed is probably accessed out of bounds. Determined data
It is because of this uncertain data that the keys are different during encryption and decryption, so the decryption is garbled.
Pump it up, don’t sink it!