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

220 questions
2
votes
2 answers

cipher.js TypeError: IV must be a buffer

var path = require('path'); var fs = require('fs'); var crypto = require('crypto'); var algorithm = 'aes-256-ctr'; var password = 'xxxxx'; var dir = '/Users/antkong/some/path'; var file = 'somefile.json'; var clearTextPath = path.join(dir,…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
2
votes
2 answers

Mongoose getters and setters not functioning properly

I'm trying to encrypt and decrypt values before and after inserting to MongoDB. I'm using mongoose schema and calling the get and set methods for encryption and decryption. The data is getting encrypted by calling set method, but while retrieving…
NagaRajendra
  • 159
  • 3
  • 16
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
  • 234
  • 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
  • 163
  • 1
  • 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,643
  • 4
  • 19
  • 31
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,585
  • 1
  • 13
  • 17
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
  • 26,448
  • 9
  • 23
  • 28
1
vote
1 answer

How to generate derive shared secret key from public key

I am reverse engineering an application. What I noticed is that in a part of this application, a request is made to the server and a key is received from the server in base64 format. Then it converts the same key into hex format and then derives…
1
vote
1 answer

How to decrypt NodeJS crypto on the client side with a known encryption key?

I am trying to have AES encryption on the server side, and decryption on the client side. I have followed an example where CryptoJS is used on the client side for encryption and SubtleCrypto on the client side as well for decryption, but in my case…
xfscrypt
  • 16
  • 5
  • 28
  • 59
1
vote
0 answers

How can I use custom padding in Node js encryption and decryption?

While I was going through a piece of code in JAVA for encryption there is padding mechanism we can provide while creating cipher instance. final Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding"); Here we can specify the…
Digvijay Rathore
  • 637
  • 1
  • 6
  • 21
1
vote
0 answers

Migrating crypto.createCipher to crypto.createCipheriv

I have existing code and passwords and other date that has been in use for 5 years and has live data that was encrypted using crypto.createCipher. Now that crypto.createCipher is deprecated, I need to migrate to new functions whilst allowing all my…
crankshaft
  • 2,607
  • 4
  • 45
  • 77
1
vote
1 answer

What are differences between `createSign()` and `privateEncrypt()` in `node:crypto` for RSA?

privateEncrypt() says "..., the padding property can be passed. Otherwise, this function uses RSA_PKCS1_PADDING." sign() says "padding Optional padding value for RSA, one of the following: crypto.constants.RSA_PKCS1_PADDING (default)". So naive…
Sergey Kaunov
  • 140
  • 1
  • 8
1
vote
1 answer

PHP encrypt and decrypt in node JS

I have a encryption in PHP and a decryption in node JS. I know there are many topics about this. But all of them state that it doesn't work. In my case it does. Well sort of. PHP define('CRYPT_KEY',…
DataConnect
  • 129
  • 1
  • 8
1
vote
1 answer

(aes-256-ctr) Is it possible to decrypt ciphertext if I only have the key and the ciphertext?

I used aes-256-ctr to decrypt some app data, but made the mistake of generating a new IV on each app startup Is there some type of attack or vulnerability that I can use to recover the IV used on the ciphertext using only that and the key? Thanks in…
1
vote
4 answers

Encrypt/decrypt string n JavaScript

I have a string, length of which is 0 <= X <= 26; I need encrypt function which will encrypt this string to get X-character-length string: encrypt("My String", "Passphrase", xLengthOutput) -> "01234567890123456789012345"; I also need decrypt…