exportRawKey abstract method

Future<Uint8List> exportRawKey()

Export HmacSecretKey as raw bytes.

This returns raw bytes making up the secret key. This does not encode the Hash hash algorithm used.

Example

import 'package:webcrypto/webcrypto.dart';

// Generate a new random HMAC secret key.
final key = await HmacSecretKey.generate(Hash.sha256);

// Extract the secret key.
final secretBytes = await key.exportRawKey();

// Print the key as base64
print(base64.encode(secretBytes));

// If we wanted to we could import the key as follows:
// key = await HmacSecretKey.importRawKey(secretBytes, Hash.sha256);

Implementation

Future<Uint8List> exportRawKey();