add ECIES browser example
This commit is contained in:
parent
586c8c0e20
commit
acd86fdc43
|
@ -0,0 +1,23 @@
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<script src="../../browser/bundle.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var bitcore = require('bitcore');
|
||||||
|
var Buffer = bitcore.Buffer;
|
||||||
|
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'));
|
||||||
|
/* Crash happens here */
|
||||||
|
var message = new Buffer('This is a message to be encrypt');
|
||||||
|
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() + '"');
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Reference in New Issue