Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: same encrypt word ?

by Loops (Curate)
on Oct 30, 2014 at 11:40 UTC ( [id://1105612]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^4: same encrypt word ?
by docofchaos (Novice) on Oct 30, 2014 at 11:55 UTC
    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 :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1105612]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 07:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found