SHARE
TWEET

Untitled

a guest Oct 21st, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const crypto = require('crypto');
  2.  
  3. const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', {
  4.   namedCurve: 'sect239k1'
  5. });
  6.  
  7. const sign = crypto.createSign('SHA256');
  8. sign.write('some data to sign');
  9. sign.end();
  10. const signature = sign.sign(privateKey);
  11.  
  12. const verify = crypto.createVerify('SHA256');
  13. verify.write('some data to sign');
  14. verify.end();
  15.  
  16.  
  17.  
  18. console.log(verify.verify(publicKey, signature));
  19.  
  20.  
  21. //console.log(publicKey.export({type:'spki', format: 'pem'}))
  22. //console.log(privateKey.export({type:'sec1', format: 'pem'}))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top