AKushWarrior / steel_crypt

A collection of high-level API's exposing PointyCastle to perform hashing and encrypting in popular/secure algorithms.
https://pub.dev/packages/steel_crypt
Mozilla Public License 2.0
40 stars 10 forks source link

How to decrypt in PHP and OpenSSL? #3

Closed emitof9999 closed 4 years ago

emitof9999 commented 4 years ago

Hi,

I totally no idea how to decrypt it in PHP and shell based OpenSSL.

Attempted to decrypt, but nothing to be print out.. Means maybe mode, IV or key is different....

Meanwhile, how to encrypt it with AES-256? It looks like not support aes-256-cbc

This is my PHP code :

openssl_decrypt(base64_decode("5hg/Q7t65Oa0uPZAKC5GJZ6JGFGvrKJzJOkNtxgkLm0="), $aes_mode, $key, OPENSSL_RAW_DATA, base64_decode($IV));

Thank you.

Regards,

Gordon

emitof9999 commented 4 years ago

Finally i found solution from others forum to resolved my problem

Dart:

  var aesEncrypter = AesCrypt('my 32 length key................', 'cbc', 'pkcs7'); //generate AES CBC block encrypter with key and PKCS7 padding
  var iv = 'my 32 length key';
  String encrypted = aesEncrypter.encrypt('somedatahere', iv); //encrypt
  String decrypted = aesEncrypter.decrypt(encrypted, iv); //decrypt

  print(encrypted);
  print(decrypted);

PHP:

var_dump(openssl_decrypt(base64_decode($ENCRYPTED_FROM_DART), "AES-256-CBC", "my 32 length key................", OPENSSL_RAW_DATA, "my 32 length key"));
AKushWarrior commented 4 years ago

Glad to hear it worked out! Thanks for your efforts, and happy coding!