exportJsonWebKey abstract method
Export AesCtrSecretKey as JSON Web Key.
The output will be given as Map
, String, List the same way
jsonDecode from dart:convert
represents decoded JSON values.
Example
import 'package:webcrypto/webcrypto.dart';
import 'dart:convert' show jsonEncode;
// Generate a new random AES-256 secret key.
final key = await AesCtrSecretKey.generate(256);
// Export the secret key.
final jwk = await key.exportJsonWebKey();
// The Map returned by `exportJsonWebKey()` can be converted to JSON with
// `jsonEncode` from `dart:convert`, this will print something like:
// {"kty": "oct", "alg": "A256CTR", "k": ...}
print(jsonEncode(jwk));
Implementation
Future<Map<String, dynamic>> exportJsonWebKey();