Questions tagged [node-rsa]

Node.js RSA library

Based on jsbn library from Tom Wu http://www-cs-students.stanford.edu/~tjw/jsbn/

  • Pure JavaScript
  • No needed OpenSSL
  • Generating keys
  • Supports long messages for encrypt/decrypt
  • Signing and verifying
26 questions
12
votes
1 answer

RSA sign in node.js and verify in C++

I'm working on a way to secure the message I sent from a node.js server to a C++ application. From node.js , I created a key pair. I'm using node-rsa to read the public key on node.js side ( https://github.com/rzcoder/node-rsa ) var rsa = new…
Nico AD
  • 1,657
  • 4
  • 31
  • 51
7
votes
3 answers

node-rsa errors when trying to decrypt message with private key

So I've been trying to use node with node-rsa and javascript with jsencrypt to create a website (for an assignment) where the javascript client gets the public key generated by the server (node-rsa), encrypts the message (jsencrypt) that the user…
5
votes
1 answer

node-rsa and openssl compatibility

I have a set of public/private keys, that works flawless when encrypting/decrypting some data using only one of the 2 ways for both encryption and decryption. I still have no luck trying to encrypt the data with the one of the two and decrypt it…
Fr0stBit
  • 1,455
  • 1
  • 13
  • 22
3
votes
1 answer

Node-rsa Encrypting Public key from the pem file and trying to decrypt, but getting following error. (probably incorrect key) NODEJS

Error: Error during decryption (probably incorrect key). Original error: Error: This is not private key Here is my nodejs code. I am using node-rsa. const keyData = fs .readFileSync("./docs/PublicKey/XXX_sandbox.pem") .toString(); …
Monish N
  • 330
  • 1
  • 6
  • 15
3
votes
1 answer

Typescript compilation for module imports

I am working with an npm module (node-rsa), trying to use typescript. In the example for my module, I need to write some js like this (taken from the module docs). var NodeRSA = require('node-rsa'); var key = new NodeRSA({b: 512}); However, when I…
George Edwards
  • 8,979
  • 20
  • 78
  • 161
3
votes
3 answers

node-rsa : InvalidAsn1Error: encoding too long

I am using node-rsa module for decrypt the key . I have created one private key from p12 file by using below command openssl pkcs12 -in xxx.p12 -nocerts -out privateKeyPkcs12.pem it has given rsa private key so i have tried to create key by using…
Prabu
  • 155
  • 3
  • 14
2
votes
2 answers

Signing/Decoding with Base-64 PKCS-8 in Node.js

Currently working to try to get connected with the Walmart Partners API, and having some issues with their cryptography, and I have not found any documented assistance for this in Javascript/Node. The documentation states: Sign the byte array…
n drosos
  • 171
  • 2
  • 10
1
vote
0 answers

Node-RSA decryption very slow in React Native

I tried to decrypt a string encrypted with a publicKey on the server using Node-RSA in my React Native app with the privateKey using the same Node-RSA lib, it takes about 2-3 secs to decrypt a simple object containing only userId and iat. const…
Eddie
  • 31
  • 1
  • 5
1
vote
1 answer

Buffer library in browser does not return the same value as in nodejs

When running the Buffer.from static method in node js on a public key I get different console.log when running it from the browser (in an angular project). Should'nt they be the same? Is there something I'm doing wrong? const…
Han Che
  • 8,239
  • 19
  • 70
  • 116
1
vote
0 answers

Node.js - node-rsa - Error during encryption. Original error: Error: error:0306E06C:bignum routines:BN_mod_inverse:no inverse

I`m trying to encrypt data via RSA using public key (128-bytes == 1024-bits) received from auth server. Here is a code in Node.js: const NodeRSA = require('node-rsa'); const openData = Buffer.from('example'); const rsaPublicKey = Buffer.from('04 D4…
xOk
  • 19
  • 2
1
vote
2 answers

How do I decrypt a file using node-rsa with public and private keys?

I was following this tutorial on medium. However the tutorial does not explain how to decrypt the encrypted file. Nor does it explain how the public / private keys are used. Simply running decrypt does not work with the error below. Relevant…
user10799425
1
vote
1 answer

node-rsa decryption doesn't work

I tried to implement rsa public key system. the server was implemented with node-js and using node-rsa library to encrypt/decrypt rsa. and the client was implemented with java. in authentification part, the client(java) encrypt client's id and…
user3867261
  • 109
  • 1
  • 2
  • 7
0
votes
1 answer

node-rsa fails to decrypt

On the client side, import JSEncrypt from 'jsencrypt'; var cryptor = new JSEncrypt(); const publicEncrypt = (str:string, publicKey:string = PUBLIC_KEY) =>{ cryptor.setPublicKey(publicKey); return cryptor.encrypt(str) } //…
user824624
  • 7,077
  • 27
  • 106
  • 183
0
votes
0 answers

The same set of public and private key encrypted text produces different types of variables?

function encrypt(encrypted, publicKey) { const encrypt = crypto.publicEncrypt(publicKey, Buffer.from(encrypted)); return encrypt; } var ciphertext = this.encrypt("***",key.exportKey('public')) Use the public and private keys generated by…
李海龙
  • 1
  • 1
0
votes
2 answers

Convert jwk to pem in nest.js

I have this jwk key that I wanto convert into pem: const jwkey = { kty: 'RSA', kid: 'eecb0ced-4d49-4100-9547-841e4100b756', n: '...very long string', e: 'AQAB', alg: 'RS256', use: 'sig', }; I have tried the libraries like jose, node-rsa…
1
2