How to use the public-encrypt/browser.publicDecrypt function in public-encrypt

To help you get started, we’ve selected a few public-encrypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tradle / react-native-crypto / test / public-encrypt.js View on Github external
t.test('can round trip', function (t) {
    t.plan(2)
    var msg = 'this is a message'
    // note encryption is ranomized so can't test to see if they encrypt the same
    t.equals(crypto1.publicDecrypt(rsa.public, crypto2.privateEncrypt(rsa.private, new Buffer(msg))).toString(), msg, 'round trip it')
    t.equals(crypto2.publicDecrypt(rsa.public, crypto1.privateEncrypt(rsa.private, new Buffer(msg))).toString(), msg, 'round trip it')
  })
})