php - TripleDES - phpseclib equivalent of C# code -


i'm using phpseclib doing triple des encryption.

this have encryption.

<?php  use phpseclib\crypt\tripledes;  class foo {      public function encrypt()     {         $encryptme = new tripledes();         $encryptme->setkey(md5('cevu4mhkqz7mqgeqmb6mqexi'));         $encryptme->setiv('jvz8buax');         $encryptme->paddable = false;          $ciphertext = $encryptme->encrypt("{phrase:'user123',time:'9/11/2017 02:27:19 pm',username:'user1'}");          return rawurlencode(base64_encode($ciphertext));         // result : uru1%2bupn7oelxj7ngpkkpok%2foiw8soizr8fbdvx4wicxi8dvy4kcau1fsuvaknf1olvr1g4rg0yd2lyl%2fnu7zdwv4cgxvq%2fl     }  } 

it works it's not having same result of c# code here: http://rextester.com/knjgp9315

// c# result : hq3bjmupqu6kuvjq3aopvqfopooaad0rgofcidj6u9uir%2bjloas2x7klhsfwhpteuoez5ipernbjnwzmofm1aw%3d%3d 

edit:

my c# triple des setting follows:

mode = cbc

padding = zeros

i think missed setting or something. do!

update php setkey() line to:

$encryptme->setkey(md5('cevu4mhkqz7mqgeqmb6mqexi', true)); 

and result is:

hq3bjmupqu6kuvjq3aopvqfopooaad0rgofcidj6u9uir%2bjloas2x7klhsfwhpteuoez5ipernbjnwzmofm1aw%3d%3d


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -