dh 0.1.0 copy "dh: ^0.1.0" to clipboard
dh: ^0.1.0 copied to clipboard

Dart 1 only

Diffie-Hellman Key-exchange algorithm in Dart

dh #

Diffie-Hellman Key-exchange algorithm in Dart

Example #

import 'package:dh/dh.dart';

main() {
  // Generate Alice's keys...
  DhGroup alice = new DhGroup.byGroupId(14);
  DhKey aliceKey = alice.generateKey();
  String alicePubKey = aliceKey.publicKey;

  // Generate Bob's keys...
  DhGroup bob = new DhGroup(alice.prime, alice.generator);
  DhKey bobKey = bob.generateKey();
  String bobPubKey = bobKey.publicKey;

  // Exchange and generate the secret...
  int secretKey1 = aliceKey.computeKey(new DhKey.fromPublicKey(bobPubKey));
  int secretKey2 = bobKey.computeKey(new DhKey.fromPublicKey(alicePubKey));

  // OK
  print(secretKey1);
  print(secretKey1 == secretKey2);
}

1
likes
30
pub points
29%
popularity

Publisher

unverified uploader

Diffie-Hellman Key-exchange algorithm in Dart

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

More

Packages that depend on dh