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
1 answer

WebCrypto Generate ECDSA signature in base64

I wanna generate an ECDSA signature and convert it to base64. I can easily accomplish this with Nodejs: const sign = crypto.createSign('SHA256') sign.update('part1') sign.update('part2') const signature = sign.sign(privateKey,…
0
votes
0 answers

Node Crypto Error - wrong final block length

I am getting an error when decrypting a response using crypto that i don't understand Error: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length I'm decrypting a response that looks like this…
Richlewis
  • 15,070
  • 37
  • 122
  • 283
0
votes
1 answer

Is it considered a bad practice to use the same initial vector for encryption although I have to

I am making an application that has the national id of a user as a column, sure this data is sensitive so it has to be encrypted so I am using node JS crypto library for encryption and using the createCipheriv method to encrypt it as createCipher is…
Omar-JR
  • 15
  • 1
  • 6
0
votes
1 answer

How can I get the same result from DecryptStringFromBytes_Aes that I have in .NET C # but in Node js?

I need to get in Node js the same decrypted value that I get from my website in .NET C # My code in the .NET C # class called Crypto is: private static readonly string key = "Z8,omB0pxZwñ3h9s"; public string Encrypt(string data) { …
0
votes
1 answer

GO decryption nodejs has been deprecated data encryption method?

This is a 4 year old nodejs project I took over, and I was asked to refactor it using golang, but in the refactoring I found that the nodejs encryption was deprecated. And, I don't know which mode of AES is used to encrypt this code Can any expert…
0
votes
0 answers

How to solve the error format of input to decryption of Elliptic curve cryptography?

I have a client/server application to encrypt/decrypt data. Client node encrypts a JSON data using ECIES from this library JavaScript Elliptic curve cryptography library. Then, node sends it to the server side using MQTT protocol. Server node…
ismsm
  • 143
  • 2
  • 11
0
votes
0 answers

How to use OAEP encrypt data with this public key

I am re-writing a Java application with NodeJS. I need to encrypt a message using these parameters but I cannot get it work. { "oaepHashAlgo": "SHA256", "pubKeyIndex": "0004", "Sid":…
Hereblur
  • 2,084
  • 1
  • 19
  • 22
0
votes
1 answer

How to format data to correctly decrypt hex strings in CryptoJS

I have a TCP server that is receiving information via direct IP. I am receiving this information encrypted in AES-128-CBC.(hex byte buffer) I then turn the buffer into a string of hex bytes with no spaces. "originalMsg" I get passed the IV, the…
Yewla
  • 325
  • 3
  • 21
0
votes
1 answer

Diffie Hellman algorithm on browser

NodeJS have crypto module where DiffieHellman is a class. So, I can use this method to generate key and compute key. But, client also need to create another instance of diffiehellman class. But how to do that? Can I use crypto module on client side?…
0
votes
1 answer

How to do AES128 decryption in C#?

I have a function which try to decyrpt a byte array in C#. Decryption function: string Decrypt(byte[] cipherText, byte[] Key, byte[] IV) { string plaintext = null; // Create AesManaged using (AesManaged aes = new…
Akif Çelebi
  • 41
  • 2
  • 8
0
votes
1 answer

How to do Hybrid Encryption in NodeJS in given below steps?

Steps for Encryption 1) Generate a 16 digits random number. Say RANDOMNO. 2) Encrypt RANDOMNO using RSA/ECB/PKCS1Padding and encode using Base64. Say encryptedKey. 3) Perform AES/CBC/PKCS5Padding encryption on request payload using RANDOMNO as a key…
0
votes
1 answer

How to encrypt a stream in node js

How to encrypt and decrypt a stream in node js without saving the file locally or converting it into buffer. if there is no way then pls provide memory efficient and less storage consuming way to encrypt and decrypt stream in node js so that i can…
0
votes
1 answer

nodejs crypto.createhash('sha256') produces different hash for the same S3 object

Every time I test my code it produces a different hash even though it is the same file/object from S3. Here is my code: "use strict"; var crypto = require('crypto'); let AWS = require("aws-sdk/global"); AWS.config.update({region:…
KingAndrew
  • 1,164
  • 4
  • 21
  • 41
0
votes
1 answer

How to decrypt a HEX buffer with RC4?

I just can't seem to decrypt a hex buffer, which I'm pretty sure is encrypted with RC4 and which I'm pretty sure I know the key. Being a beginner in cryptography, I just want to make sure I'm actually doing everything right before starting to think…
Maxime Dupré
  • 5,319
  • 7
  • 38
  • 72
0
votes
0 answers

while decrypting with wrong key in node js, the app is crashed even though it is properly enclosed in try catch

The App works fine when I use the correct decryption key but when I use the wrong deryption key the whole app is crashed.This is the block of code I am using to retrieve the data from the file, decrypt it and send it in the response. try{ const…
Prabu M
  • 109
  • 2
  • 8