I am working on linux/ubuntu. I found out that mcrypt is automatically included as a library in this platform. I want to create an encryption with aes 256 and cbc padding 7 (iv). Could someone please give me an example of how to encrypt a string with aes 256 and cbc iv, padding 7?
Rijndael is the same with aes.!
this is the link i've found with the library i would like to use: http://linux.die.net/man/3/mcrypt
Are you asking how to use
mcrypt
? Here's a basic skeleton:You have to check the actual key size and IV size with
mcrypt_enc_get_key_size(td)
andmcrypt_enc_get_iv_size(td)
and provide suitable key and IV data.Edit: Because it's so simple, here's an algorithm to add and strip PCKS7 padding:
(Library-grade code would of course test that
n
can be represented by achar
, and that during stripping the input string is non-empty and the padding is valid.)