forked from menlatin/flappycore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan X. Charles
committed
Jun 6, 2014
1 parent
6aef44e
commit 261a94d
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var run = function() { | ||
bitcore = typeof (bitcore) === 'undefined' ? require('../bitcore') : bitcore; | ||
|
||
console.log('ECIES: Elliptic Curve Integrated Encryption Scheme'); | ||
console.log('A way of encrypting with a public key and decrypting with a private key.'); | ||
|
||
var key = bitcore.Key.generateSync(); | ||
console.log('Private key: ' + key.private.toString('hex')); | ||
console.log('Public key: ' + key.public.toString('hex')); | ||
|
||
var message = new Buffer('This is a message to be encrypted'); | ||
console.log('Message: "' + message.toString() + '"'); | ||
|
||
var encrypted = bitcore.ECIES.encrypt(key.public, message); | ||
console.log('Encrypted (with public key): ' + encrypted.toString('hex')); | ||
|
||
var decrypted = bitcore.ECIES.decrypt(key.private, encrypted); | ||
console.log('Decrypted (with private key): "' + decrypted.toString() + '"'); | ||
}; | ||
|
||
|
||
// This is just for browser & mocha compatibility | ||
if (typeof module !== 'undefined') { | ||
module.exports.run = run; | ||
if (require.main === module) { | ||
run(); | ||
} | ||
} else { | ||
run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters