decryptFast static method

String decryptFast({
  1. required String encryptedData,
  2. required String userKey,
})

快速解密

Implementation

static String decryptFast({
  required String encryptedData,
  required String userKey,
}) {
  final parts = encryptedData.split(':');
  if (parts.length != 2) {
    throw const FormatException('Invalid encrypted data format');
  }

  final iv = IV.fromBase64(parts[0]);
  final encrypted = Encrypted.fromBase64(parts[1]);

  final keyBytes = _ensureKeyLength(userKey);
  final key = Key.fromBase64(keyBytes);

  final encrypter = Encrypter(AES(key, mode: AESMode.ctr));
  return encrypter.decrypt(encrypted, iv: iv);
}