exportSpkiKey abstract method

Future<Uint8List> exportSpkiKey()

Export RSASSA-PSS public key in SPKI format.

Returns the DER encoding of the SubjectPublicKeyInfo structure specified in RFC 5280 as a list of bytes.

Example

import 'package:webcrypto/webcrypto.dart';
import 'package:pem/pem.dart';

// Generate a key-pair.
final keyPair = await RsaPssPrivateKey.generateKey(
  4096,
  BigInt.from(65537),
  Hash.sha256,
);

// Export the public key.
final rawPublicKey = await keyPair.publicKey.exportSpkiKey();

// Public keys are often encoded as PEM.
// This encode the key in base64 and wraps it with:
// '-----BEGIN PUBLIC KEY-----'...
print(PemCodec(PemLabel.publicKey).encode(rawPublicKey));

Implementation

Future<Uint8List> exportSpkiKey();