encrypt static method
Encryption
@param textToEncrypt @param key @return
Implementation
/*static String encrypt(final String textToEncrypt, final String key) {
try {
final Cipher cipher = Cipher.getInstance(PADDING);
cipher.init(Cipher.ENCRYPT_MODE, makeKey(key), makeIv());
return new String(Base64.encodeBase64(cipher.doFinal(textToEncrypt.getBytes())));
} catch (final Exception e) {
throw new RuntimeException(e);
}
}*/
static String? encrypt(final String textToEncrypt, 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 encrypted = encrypter.encrypt(textToEncrypt, iv: iv);
/*material.debugPrint('String to encrypt is $textToEncrypt');
material.debugPrint('String key using to encrypt is $strKey');
material.debugPrint('Encrypted string is ${encrypted.base64}');*/
return encrypted.base64;
}