importAesKey function

Future<AesGcmSecretKey> importAesKey(
  1. String key, [
  2. ByteBuffer? salt,
  3. DefaultAESKey? opt
])

Implementation

Future<crypto.AesGcmSecretKey> importAesKey(String key,
    [ByteBuffer? salt, DefaultAESKey? opt]) async {
  opt ??= DEFAULT_OPTS;

  final combo = key + (salt?.asUint8List() ?? Shims.random(8)).toString();
  final hash = await sha256(combo);
  final jwkKey = keyToJwk(hash);
  return crypto.AesGcmSecretKey.importJsonWebKey(jwkKey.toJson());
}