secp256k1cipher 0.3.0 copy "secp256k1cipher: ^0.3.0" to clipboard
secp256k1cipher: ^0.3.0 copied to clipboard

Encrypt and decrypt data use secp256k1, This is the High level API build amount pointycastle, specify Elliptic curve to secp256k1 can simplify the api.

example/main.dart

import 'package:secp256k1cipher/secp256k1cipher.dart';

void main() {
  // var alic = generateKeyPair(); // Create Alic keypair
  // var bob = generateKeyPair();  // Create Bob keypair
  // var raw_str = 'Encrypt and decrypt data use secp256k1';  // This is what alic want to say to bob
  // var enc_map = pubkeyEncrypt(strinifyPrivateKey(alic.privateKey), strinifyPublicKey(bob.publicKey), raw_str); // use alic's privatekey and bob's publickey means alic say to bob
  // var enc_str = enc_map['enc']; // Get encrypted base64 string
  // var iv = enc_map['iv'];       // Get random IV
  // next thing, you can send enc_str and IV via internet to bob
  // var decryptd = privateDecrypt(strinifyPrivateKey(bob.privateKey), strinifyPublicKey(alic.publicKey), enc_str, iv); // use bob's privatekey and alic's publickey means bob can read message from alic
  // print('alic say:${decryptd}');

  // final kp = generateKeyPair();
  // print('pubic: ${strinifyPublicKey(kp.publicKey)}');
  // print('private: ${strinifyPrivateKey(kp.privateKey)}');
  // print('');
  // print('');

  /*
  final tempKeypair = generateKeyPair();
  final clientPublickey =
      '027770618004184e7d6378a31e7d14dadf0a6e445c8bacf4d471fd356804a45e28';

  final clientPrivate =
      'da19f770c17f48cd3bd9513b91e75015e138032d9433a810910788487e69a62c';

  final enc = pubkeyEncrypt(
      strinifyPrivateKey(tempKeypair.privateKey), clientPublickey, 'test test');
  print(enc);
  print(strinifyPublicKey(tempKeypair.publicKey));

  final raw = privateDecrypt(clientPrivate,
      strinifyPublicKey(tempKeypair.publicKey), enc['enc'], enc['iv']);
  print(raw);
   */

  final alice = generateKeyPair();
  final bob = generateKeyPair();
  print('alice_public = \"${strinifyPublicKey(alice.publicKey)}\"');
  print('alice_private = \"${strinifyPrivateKey(alice.privateKey)}\"');
  print('bob_public = \"${strinifyPublicKey(bob.publicKey)}');
  print('bob_public = \"${strinifyPrivateKey(bob.privateKey)}\"');
}
8
likes
150
points
50
downloads

Publisher

unverified uploader

Weekly Downloads

Encrypt and decrypt data use secp256k1, This is the High level API build amount pointycastle, specify Elliptic curve to secp256k1 can simplify the api.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

base58check, hex, pointycastle

More

Packages that depend on secp256k1cipher