in reply to Re: same encrypt word ?
in thread same encrypt word ?

hi, yes i can make an example of result

with the php function :
key : test-math
encrypted text :
c2dbe4b6fec504f3249e2866dacc2a000964136de054865d407321433c001f98
decrypted text: test-math

and it's the same result every time, i don't give another argument on the php function.
I can decrypt the text with all online tool, if i choose the RIJNDAEL_256 and ECB mode.
I have no idea to have the same result with perl function

Replies are listed 'Best First'.
Re^3: same encrypt word ?
by Loops (Curate) on Oct 30, 2014 at 11:40 UTC

    Okay, this algorithm requires both the key and the data to be in blocks of 16. So you may be running into differences in the way they're being automatically padded for you.

    If you set both the plain text and the key to "1234567890123456", you'll see it's encrypted as: "757ccd0cdc5c90eadbeeecf638dd0000". You can verify this yourself by using this online tool.

    use Crypt::Rijndael; my $plaintext = my $key = '1234567890123456'; my $cipher = Crypt::Rijndael->new( $key, Crypt::Rijndael::MODE_ECB ); my $encrypted = $cipher->encrypt($plaintext); printf "%02x", ord $_ for split //, $encrypted;
    Prints: 757ccd0cdc5c90eadbeeecf638dd0000. So hopefully that's what you're getting with your PHP as well.

    Update: Ah, I see that all the above was done using 128-bit ECB, and you're using 256-bit.. hmmm.

    By the way, Crypt::Rijndael says in no uncertain terms that ECB should be avoided

      hi ty for the answer, but i used rijndael_256, anf i can't decryp the text with http://rijndael.online-domain-tools.com/ i'll try to format my key to be in 16 blocksize.
      print "\n---- Test6 -------- \n"; my $key_6 = 'test-math'; $key_6 .= "\0" x (16 - length($key_6)); my $plaintext_6 = 'test-math'; my $cipher_6 = Crypt::Rijndael->new( $key_6, Crypt::Rijndael:: +MODE_ECB ); my $encrypted_6 = $cipher_6->encrypt($plaintext_6); printf "%02x", ord $_ for split //, $encrypted_6; print "---- Fin test 6 ---\n";
      i have an error like 'datasize not multiple of blocksize (16 bytes)' i'll find a way to use your code and adapt your code
      thanks to your answer and i hope it work :)