Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2. $key = '';
  3. $cipher = new \phpseclib\Crypt\TripleDES(\phpseclib\Crypt\DES::MODE_CBC);
  4. $cipher->setPreferredEngine(\phpseclib\Crypt\DES::ENGINE_INTERNAL);
  5.  
  6. //my key is hex format
  7. $key = str_repeat('0', 24*2);
  8. $cipher->setKey(hex2bin($key));
  9. $cipher->setIV(hex2bin('0000000000000000'));
  10.  
  11. //my data is hex format
  12. $data = str_repeat('0', 8*2*2);
  13. $plaintext = hex2bin($data);
  14.  
  15. $ciphertext = $cipher->encrypt($plaintext);
  16. echo bin2hex($ciphertext) . "\n";
  17. echo bin2hex($cipher->decrypt($ciphertext));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement