Skip to content
/ ecdh-es Public

Elliptic Curve Diffie-Hellman with ephemeral-static keys implementation for NodeJS

Notifications You must be signed in to change notification settings

shesek/ecdh-es

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecdh-es npm npm

Elliptic Curve Diffie-Hellman with ephemeral-static keys implementation for NodeJS

Install

npm install --save ecdh-es

Use

var ecdh = require('ecdh-es')
  , pubkey = new Buffer('03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd', 'hex')
  , privkey = new Buffer('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'hex')

var encrypted = ecdh.encrypt(pubkey, 'Hello, world!') // -> Buffer
var decrypted = ecdh.decrypt(privkey, encrypted) // -> Buffer
// (use toString() to convert back to string message)

// Uses the secp256k1 curve and AES-128-CBC cipher by default,
// but can be overridden as follows:
var ecdh = require('ecdh-es')({
  curve_name: 'secp192k1',
  cipher_algo: 'AES-256-CBC',
  key_size: 32,
  iv_size: 16
})

Browser usage

If you're using browserify to bundle your code, you can use this package normally and everything should work the same. Note, however, that crypto-browserify (which is used as a shim for nodejs's crypto api) only support AES encryption.

If you're not using browserify, you can use the standalone bundle at dist/ecdh.min.js, which comes packaged with all of the dependencies. Including it in your page will provide global ECDH object you can use.

License

MIT

About

Elliptic Curve Diffie-Hellman with ephemeral-static keys implementation for NodeJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published