Guest User

Untitled

a guest
Jan 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. const EthCrypto = require('eth-crypto');
  2.  
  3. const privKey = "0xd9c3501c110a83bb22c319e4c50b9169f2fee017d98dc22c9af624adb6f10130";
  4. //const pubKey = "4f3fc0bebdeeeffd0d94afa321d8d3f8b3373a6910438842bde9808cffef0ccc261b5b5171c730a164e4d4108927e6e18fb757f81d2d4234e7cc14e2507c49ba";
  5. const message = "testMessage"
  6.  
  7. const derivedPublicKey = EthCrypto.publicKeyByPrivateKey(testPriv
  8. );
  9.  
  10. async function main() {
  11.  
  12. const encrypted = await EthCrypto.encryptWithPublicKey(
  13. pubKey, // publicKey
  14. message // message
  15. );
  16.  
  17. console.log({encrypted});
  18.  
  19. const decryptedMessage = await EthCrypto.decryptWithPrivateKey(
  20. privKey, // privateKey
  21. encrypted
  22. // encrypted-data
  23. );
Add Comment
Please, Sign In to add comment