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
0
votes
0 answers

AES256 NodeJS Decrypt

My clean data is : Test12345678910 My secret key is : 12345678901234561234567890123456 When i encrypt the data i get this output : ldJbAK2rYjDnS6kWz2O+Aw== when i decrypt it i get error internal/crypto/cipher.js:164 const ret =…
Somomo1q
  • 655
  • 2
  • 10
  • 19
0
votes
1 answer

Node JS decipher not working on Ubuntu server

I have a Cipher which can takes a key. It can then "encrypt" and "decrypt" strings. This is the error: Error: Unsupported state or unable to authenticate data 0|ts-node | at Decipheriv.final (crypto.js:183:26) This is my…
Seph Reed
  • 8,797
  • 11
  • 60
  • 125
0
votes
2 answers

Encryption on crypto-js and decryption on node crypto using CTR mode issue

I am trying to encrypt data using crypto-js javascript library and trying to decrypt the same encrypted text on nodejs side using node crypto library. I am using AES 256 encryption algo with CTR mode with no padding. I am able to encrypt properly…
user3314492
  • 233
  • 5
  • 17
0
votes
0 answers

AES 256 Encryption Decryption,

Decryption logic is missing something can you please assist. Output is not completely decrypted. Java Encryption Logic: public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,…
Sandra Pavan
  • 194
  • 1
  • 2
  • 8
0
votes
0 answers

Decrypt text in Node.js encrypted in C#

I have some text encrypted in C#/.NET which I want to decrypt in Node.js. I have the decryption code that works perfectly fine in C#, but I am not able to find code that decrypts the same encrypted text in Node.js. Below mentioned is the code in…
Anee
  • 463
  • 9
  • 26
0
votes
1 answer

Node 'crypto' SHA256 hashing model behaving erratically

I have a function that takes a file and finds its SHA256 hash. Each time I resubmit a file, it produces a different hash for the same file. On the first submission, it produces the correct hash. Each re-submission produces an incorrect hash. If I…
Hanley Soilsmith
  • 579
  • 2
  • 9
  • 27
0
votes
0 answers

Encrypt with CryptoJS.. Decrypt with Node Crypto lib

I'm trying to do a simple encryption with Crypto.js and then do the decryption with the Node.js crypto library. const crypto = require('crypto') const CryptoJS = require('crypto-js') const message = 'Hello World' const key =…
Sean Lynch
  • 2,852
  • 4
  • 32
  • 46
0
votes
1 answer

Node HMAC results differ from both Ruby and Java

I have 2 existing implementations of an HMAC hash for a 3rd party API. Java and Ruby match perfectly when doing SHA1 or SHA256, but Node doesn't match either. The code to implement in Node seems simple and straight forward, so I'm not sure where…
Soabirw
  • 43
  • 9
0
votes
2 answers

Why each time I run encrypt with simple-encryptor npm, it output difference result

Please help me resolve this problem. var key = 'real secret keys should be long and random'; // Create an encryptor: var encryptor = require('simple-encryptor')(key); var encrypted = encryptor.encrypt('testing'); // Should print…
0
votes
1 answer

Decrypt encrypted string using PKCS1-OAEP in node.js

I am getting an information which is encrypted using PKCS1-OAEP algorithm in python and I want to decrypt the information in node.js. I found the crypto library of node.js. Looks like there are two functions to decrypt this info: a) createCipherIV…
Neetu Soni
  • 51
  • 3
0
votes
1 answer

Java AES/CBC/NoPadding equivalent in NodeJs

I have been assigned to decode tokens built in java using AES/CBC/NoPadding. I am looking into node-forge and crypto for this. My problem is that I don't know what is the equivalent for the algorithm AES/CBC/NoPadding in NodeJs. I'm using something…
0
votes
1 answer

encrypt the audio file by android and decrypt it by backend sails js

I want to encrypt the audio file by android and decrypt it by backend sails js. I developed the program for that but I got error in sails js like error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt This is my source code…
Bumblebee
  • 21
  • 5
0
votes
0 answers

Convert C# function into a nodeJS function

I am trying to replicate this C# function into a NodeJS function. Here is the C# function first. private byte[] Decrypt(byte[] plainText) { using (var aes = new AesManaged()) { aes.Mode =…
Dave
  • 332
  • 1
  • 5
  • 23
0
votes
1 answer

HMAC changes according to node version (paybox module)

I am using https://www.npmjs.com/package/paybox and I need to upgrade my node version (from 5.6 to 6+) As you can see below, the generateHMAC creates a hash that differs if I change my version of node. Can you help me understand this, and tell me…
dao hodac
  • 361
  • 2
  • 5
  • 14
0
votes
1 answer

Crypto module is not working with latest node 7.10

The following code snippet is working in Node 0.12.18 (replace Buffer.from to new Buffer) but it's not working with the latest Node version (7.10.0) Can anybody explain me why this is happening?? Anything is missing in below code. /* Node.js…
Manish Trivedi
  • 3,481
  • 5
  • 23
  • 29