Created
January 15, 2015 20:51
-
-
Save maraoz/43ab4c787c46f5caa490 to your computer and use it in GitHub Desktop.
bitcore browser submodule example usage
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Bitcore ECIES browser usage</title> | |
<script src="bitcore.min.js"></script> | |
<script src="bitcore-ecies.min.js"></script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var bitcore = require('bitcore'); | |
var ECIES = require('bitcore-ecies'); | |
var PrivateKey = bitcore.PrivateKey; | |
var alice = new PrivateKey(); | |
var bob = new PrivateKey(); | |
var message = 'a secret message!1!!'; | |
var encryptor = new ECIES() | |
.privateKey(alice) | |
.publicKey(bob.toPublicKey()); | |
var encrypted = encryptor.encrypt(message); | |
console.log(encrypted.toString()); | |
var decryptor = new ECIES() | |
.privateKey(bob) | |
.publicKey(alice.toPublicKey()); | |
var decrypted = decryptor.decrypt(encrypted); | |
console.log(decrypted.toString()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment