#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    PHP AES Encryption to Coldfusion


    Hi, i have an AES Encrypted String from PHP
    Code:
    $data='sickstring';
    $key = base64_decode('LP+Rc9e1q5ajWPD9djDkLQ==');
    echo base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $maus, MCRYPT_MODE_ECB));
    The Result is

    E4Q6oR7XEyYtZAPSYjdXoQ== --> (sickstring)

    I can decrypt this in php with

    Code:
    $key = base64_decode('LP+Rc9e1q5ajWPD9djDkLQ==');
    $data = base64_decode('E4Q6oR7XEyYtZAPSYjdXoQ==');
    
    echo mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_ECB);
    But i want to decrypt this Sring with Coldfusion.

    Code:
    <cfdump var="#decrypt("E4Q6oR7XEyYtZAPSYjdXoQ==", "LP+Rc9e1q5ajWPD9djDkLQ==", "AES", "Base64")#">>
    But i got an error:
    Code:
    Given final block not properly padded
    any help?
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    Seems like it's a mismatch between the encryption and decryption algorithm. About the only thing I can offer is to have a look at this and see if it covers your situation: http://stackoverflow.com/questions/3...-string-in-php

    Or maybe this: http://stackoverflow.com/questions/1...ferent-results.

    I'd say the best way to test would be to create the CFML code that will create the same encrypted value, then you know you're on the right track and decrypting it should be straightforward.
    Last edited by kiteless; July 17th, 2012 at 10:05 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0
    many thankz.

    ....../questions/3196846/un-encrypting-re-encrypting-a-coldfusion-encrypted-string-in-php

    will work

    PHP Code:
    $pad 16 - (StrLen($data) % 16);
    if (
    $pad 0) {
         
    $data .= Str_repeat(Chr($pad), $pad);

    gotcha

IMN logo majestic logo threadwatch logo seochat tools logo