decryptMethod method
Decrypts the method using saltBase64 as a cipher, then checks that
its valid
throws a NotMethodException if method is not a method and
checkMethodValid is true
Implementation
String decryptMethod(String method, {bool checkMethodValid = true}) {
final decrypter = Encrypter(AES(Key.fromBase64(saltBase64)));
final decryptedMethodDoubled = decrypter.decrypt(
Encrypted.from64(method),
iv: IV.fromBase64(ivBase64),
);
final decryptedMethod =
decryptedMethodDoubled.substring(decryptedMethodDoubled.length ~/ 2);
if (checkMethodValid) {
if (!isMethod(decryptedMethod)) {
throw NotMethodException(method: method, encrypted: true);
}
}
return decryptedMethod;
}