https://github.com/kripod/elgamal.js
ElGamal cryptosystem for JavaScript.
https://github.com/kripod/elgamal.js
Last synced: about 1 year ago
JSON representation
ElGamal cryptosystem for JavaScript.
- Host: GitHub
- URL: https://github.com/kripod/elgamal.js
- Owner: kripod
- License: mit
- Created: 2016-05-12T19:16:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-26T07:49:53.000Z (about 10 years ago)
- Last Synced: 2025-03-29T05:33:13.810Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 26
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# elgamal.js
ElGamal cryptosystem for JavaScript based on the implementation of
[PyCrypto](https://github.com/dlitz/pycrypto).
[](https://npmjs.com/package/elgamal)
[](https://travis-ci.org/kripod/elgamal.js)
[](https://codecov.io/gh/kripod/elgamal.js)
[](https://gitter.im/kripod/elgamal.js)
## Getting started
In order to access the provided cryptographic functions, an instance of ElGamal
should be generated or initialized with custom parameters.
``` js
import ElGamal from 'elgamal';
const eg = await ElGamal.generateAsync(); // Recommended way of initialization
const egCustom = new ElGamal(prime, generator, publicKey, privateKey);
```
### Encryption and decryption
```js
const secret = 'The quick brown fox jumps over the lazy dog';
const encrypted = await eg.encryptAsync(secret);
const decrypted = await eg.decryptAsync(encrypted);
console.log(decrypted.toString() === secret); // true
```