function encrypt_text($plain_text, $key){ bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $plain_text, MCRYPT_MODE_ECB)); return $encrypt_text; } #### use Crypt::Rijndael; use Crypt::CBC; sub chiffrer_string($plain_text, $key){ $key =~ pack('H*', $key); my $cipher = Crypt::CBC->new( -key => $key, -algorithm => 'RIJNDAEL_256', -mode => 'MODE_ECB', -padding => 'null', ) || die "Couldn't create CBC object"; my $cipher_text = $cipher->encrypt($plain_text); my $cipher_block = unpack ("H*", $cipher_text); return $cipher_block;