Questions tagged [node-crypto]

Node.js crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign and verify functions. Use this tag for questions related to Node.js applications/scripts that use crypto module - require('crypto').

should be used on questions related to cryptography api of

The crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign and verify functions.

Sample

// Import module.
const crypto = require('crypto');

// Prepare secret.
const secret = 'very secret';

// Create hash.
const hash = crypto.createHmac('sha256', secret)
                   .update('sample information')
                   .digest('hex');

// Print it.
console.log(hash);
// => 5087be71f85fd1ea755742b0fe4eaf5a7c4c25bee5db58f4f7edd1558ed792d0

References

160 questions
2
votes
1 answer

NodeJS 6 crypto complaining about digest in deprecation message?

I'm trying to use the native crypto module in my NodeJS application, but I keep getting the deprecation message: (node:26) DeprecationWarning: crypto.pbkdf2 without specifying a digest is deprecated. Please specify a digest I know this is due to…
gordysc
  • 224
  • 1
  • 4
  • 22
2
votes
1 answer

NodeMCU node.js crypto

I was trying to set up an encrypted communication between node.js and NodeMCU. After some struggle, I was able to encrypt using node.js and decrypt it on NodeMCU. The reverse is not working. The reply by mscdex worked. Accordingly I modified the…
Sekar S
  • 153
  • 10
2
votes
1 answer

Crypto in Nodejs and Ruby

I want crypto a string and pass to Rails app,so I find the crypto library both in Nodejs and Ruby. In Nodejs: var crypto = require('crypto'), algorithm = 'aes-256-ctr', password = 'd6F3Efeqd6F3Efeqd6F3Efeqd6F3Efeq'; function…
HXH
  • 1,523
  • 3
  • 17
  • 26
2
votes
0 answers

Nodejs crypto setEngine

I'm trying to load gost openssl engine with crypto.setEngine function. The only working way was to specify a full path to dylib (e.g. "/opt/local/lib/engines/libgost.dylib'"). But I still can not use digest from loaded engine. Call to…
mtomy
  • 1,505
  • 1
  • 13
  • 16
1
vote
0 answers

Why do node.js crypto use binary strings?

In the node.js API 0.6.2, it is stated under the Buffer module: 'binary' - A way of encoding raw binary data into strings by using only the first 8 bits of each character. This encoding method is deprecated and should be avoided in favor of…
Betamos
  • 20,216
  • 9
  • 21
  • 27
1
vote
1 answer

Node.js: Wrong crypto output

Node.js strangely gives me wrong output when decrypting hex–encoded AES128 output. function decrypt_data( data, key, iv ) { var dc = crypto.createDecipheriv( 'aes-128-cbc', hex_to_str(key), hex_to_str(iv) ); var res = dc.update( data, 'hex',…
Aleksei Zabrodskii
  • 2,140
  • 3
  • 17
  • 41
1
vote
2 answers

Need browser equivalent of this specific implementation of crypto.createHmac method

So, I have this piece of code that's written in Node.js crypto.createHmac('sha256', secret).update(orderedParams).digest('hex') I wish to bring this piece of code in the browser but that doesn't work since the 'crypto' library is not supported on…
Anonymous
  • 1,358
  • 2
  • 12
  • 17
1
vote
1 answer

Cannot convert PHP OpenSSL IV to Node.JS

I'm trying to convert my symmetric AES-256-CBC encryption from PHP to NodeJS. But i think i'm not converting correctly the IV, and i tried different things, but not worked. My PHP Code:
1
vote
1 answer

node crypto.publicEncrypt returns different value each time it is used

I'm trying to implement basic asymmetric encryption; one service has a public key and encrypts a value with that public key and then another service receives the encrypted message, decodes it using the private key, and does something with the…
sauntimo
  • 1,129
  • 1
  • 14
  • 21
1
vote
1 answer

How to create openssl encryption and decryption equivalent of php code in nodejs application

I have an application running on php which have some values encrypted using openssl encrption by using the code below
Ajith
  • 2,227
  • 11
  • 27
1
vote
1 answer

Node crypto instead of JSEncrypt for encryption with public key

I have some public key which looks like MIIBIjANBgkqhkiG9w0BAQEFAAO... (392 chars). It used in the browser to encrypt some strings with JSEncrypt. How can I encrypt strings with that public key using NodeJS crypto module? I tried this: const crypto…
Kosteg
  • 355
  • 2
  • 9
1
vote
1 answer

How does an IV work and what would be the best way to store it?

I want to encrypt and decrypt strings. I'm using Nodejs crypto for this. I've read that when encrypting and decrypting it's highly recommended to use an IV. I want to store the encrypted data inside a MySQL database and decrypt it later when needed.…
Yuki
  • 114
  • 9
1
vote
1 answer

Encode with 'crypto-js' and decode with 'crypto' (Node)

I am encrypting a string using Advanced Encryption Standard (AES) in the browser with 'cypto-js' and need to decrypt it on the server with Node 'crypto'. I can encrypt / decrypt just fine with 'crypto-js' alone, however when I try to decrypt with…
jspru
  • 584
  • 4
  • 11
1
vote
1 answer

Unable to decrypt a pdf file Using 'aes-256-cbc' algorithm in node js

I am trying to decrypt a PDF file using node js,PDF file encrypted by third party using C# . I am having a hard time because I keep getting this error: D:\IMP\DevOps Implementation\New folder (2)> node index1.js internal/crypto/cipher.js:172 …
raviteja
  • 23
  • 4
1
vote
1 answer

How to get first 16 bytes of an SHA1 hash in node.js?

I'm trying to interoperate with a Java server. As part of the protocol, I need to create a SHA1 hash of my content. For some reason, only the first 16 bytes of the hash digest are used, encoded in Base64. The message digest is an array of bytes…
jsparkes
  • 111
  • 7