diffie_hellman 1.2.0 copy "diffie_hellman: ^1.2.0" to clipboard
diffie_hellman: ^1.2.0 copied to clipboard

Dart implementation of finite field Diffie-Hellman. Based on PKCS#3.

example/example.dart

import 'package:diffie_hellman/diffie_hellman.dart';

void main() {
  DhPkcs3Engine dhEngine = DhPkcs3Engine.fromGroup(DhGroup.g5);
  DhPkcs3Engine otherDhEngine = DhPkcs3Engine.fromGroup(DhGroup.g5);

  DhKeyPair keyPair = dhEngine.generateKeyPair();
  DhKeyPair otherKeyPair = otherDhEngine.generateKeyPair();

  print('Public key: ${keyPair.publicKey.value}');
  print('Private key: ${keyPair.privateKey.value}');
  print('Other public key: ${otherKeyPair.publicKey.value}');
  print('Other private key: ${otherKeyPair.privateKey.value}');

  print(
    'Secret key: ${dhEngine.computeSecretKey(otherKeyPair.publicKey.value)}',
  );
  print(
    'Other secret key: ${otherDhEngine.computeSecretKey(keyPair.publicKey.value)}',
  );

  print('Public key PEM: ${keyPair.publicKey.toPem()}');
  print('Other public key PEM: ${otherKeyPair.publicKey.toPem()}');

  print('Private key PEM: ${keyPair.privateKey.toPem()}');
  print('Other private key PEM: ${otherKeyPair.privateKey.toPem()}');
}
15
likes
160
points
275
downloads

Publisher

verified publisherxeertz.com

Weekly Downloads

Dart implementation of finite field Diffie-Hellman. Based on PKCS#3.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD-3-Clause (license)

Dependencies

asn1lib, equatable, meta

More

Packages that depend on diffie_hellman