diffie_hellman 1.0.0
diffie_hellman: ^1.0.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}');
print('Private Key: ${keyPair.privateKey}');
print('Other public Key: ${otherKeyPair.publicKey}');
print('Other private Key: ${otherKeyPair.privateKey}');
print(
'Secret Key: ${dhEngine.computeSecretKey(otherKeyPair.publicKey)}',
);
print(
'Other secret Key: ${otherDhEngine.computeSecretKey(keyPair.publicKey)}',
);
}