decrypt static method

String? decrypt(
  1. String textToDecrypt,
  2. String strKey
)

Decryption

@param textToDecrypt @param key @return

Implementation

/*static String decrypt(final String textToDecrypt, final String key) {
  try {
    final Cipher cipher = Cipher.getInstance(PADDING);
    cipher.init(Cipher.DECRYPT_MODE, makeKey(key), makeIv());
    return new String(cipher.doFinal(Base64.decodeBase64(textToDecrypt)));
  } catch (final Exception e) {
  throw new RuntimeException(e);
  }
}*/

static String? decrypt(final String textToDecrypt, final String strKey) {
  final Key key = Key.fromBase64(strKey);
  final IV iv = IV.fromUtf8(ENCRYPTION_IV);

  final Encrypter encrypter = Encrypter(AES(key, mode: AESMode.cbc));
  final decrypted = encrypter.decrypt(Encrypted.fromBase64(textToDecrypt), iv: iv);

  /*material.debugPrint('String to decrypt is $textToDecrypt');
  material.debugPrint('String key using to encrypt is $strKey');
  material.debugPrint('Decrypted string is $decrypted');*/

  return decrypted;
}