exportJsonWebKey abstract method
Export RSAES-OAEP public key in JSON Web Key format.
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 key-pair.
final keyPair = await RsaOaepPrivateKey.generateKey(
4096,
BigInt.from(65537),
Hash.sha256,
);
// Export the public key.
final jwk = await keypair.publicKey.exportJsonWebKey();
// The Map returned by `exportJsonWebKey()` can be converted to JSON with
// `jsonEncode` from `dart:convert`, this will print something like:
// {"kty": "RSA", "alg": "RSA-OAEP-256", ...}
print(jsonEncode(jwk));
Implementation
Future<Map<String, dynamic>> exportJsonWebKey();