Hkdf class abstract
HKDF (RFC 5869) key derivation algorithm.
DartHkdf is the pure Dart implementation of the HKDF algorithm. It's used when no faster implementation is available.
In browsers, "package:cryptography" will automatically attempt to use Web Crypto API, which has very good HKDF performance.
Flutter developers should add cryptography_flutter, as a dependency for the best possible HKDF performance.
Example
import 'package:cryptography/cryptography.dart';
void main() async {
final algorithm = Hkdf(
hmac: Hmac.sha256(),
outputLength: 32,
);
final secretKey = SecretKey([1,2,3]);
final nonce = [4,5,6];
final output = await algorithm.deriveKey(
secretKey: secretKey,
nonce: nonce,
);
}
- Inheritance
-
- Object
- KdfAlgorithm
- Hkdf
- Implementers
Constructors
- Hkdf({required Hmac hmac, required int outputLength})
-
factory
- Hkdf.constructor()
-
Constructor for classes that extend this class.
const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- hmac → Hmac
-
no setter
- outputLength → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
deriveKey(
{required SecretKey secretKey, List< int> nonce = const <int>[], List<int> info = const <int>[]}) → Future<SecretKeyData> -
Generates a new secret key from a secret key and a nonce.
override
-
deriveKeyFromPassword(
{required String password, required List< int> nonce}) → Future<SecretKey> -
Generates a new secret key from a
password
and anonce
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override