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

Using AES GCM without authentication tag in Node.js?

I'm using node:crypto API, namely createCipheriv() and createDecipheriv() with aes-256-gcm cipher to encode/decode a stream of data. However, it looks like I need to call decipher.setAuthTag() in order to decode the stream correctly, otherwise it…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
0
votes
1 answer

Encryption & decryption in node aes-256-cbc goes Error

i need to encrypt my data with given key using aes-256-cbc algorithm but i am getting error "RangeError: Invalid key length" in node while using crypto library. Php code results "w8mBJyHzQ3yJlkSvAX8t3qy9GVaUvBiOBAPFDXOzFMQ=" with key =…
0
votes
0 answers

Node crypto error when decrypting file - 'Unsupported state or unable to authenticate data'

Iam using node crypto to encrypt files but it gives me error - "Unsupported state or unable to authenticate data" Iam using AuthTag or else it just decrypts to random text. I have not used encoding cause i wanted to encrypt all types of files…
Akshay
  • 1
  • 1
0
votes
1 answer

AES-256-CBC encryption algorithm in react-native

Hi am trying to check the compatability of encryption done on BE. BE provided the below code ` $secret_key = VALUE1`; $secret_iv = VALUE2; $encrypt_method = "AES-256-CBC"; $key = hash('sha256', $secret_key); $iv = substr(hash('sha256', $secret_iv),…
suja
  • 1,198
  • 2
  • 12
  • 32
0
votes
1 answer

Decrypt SES message from S3 with KMS

I am trying to decrypt a KMS encrypted AWS SES message stored in S3. Everything works fine (getting the object and metadata from s3, decrypting the key with KMS) until I try to decrypt the content with the decrypted Key: import { S3Client,…
Snowball
  • 1,402
  • 2
  • 17
  • 31
0
votes
0 answers

Safetyness of putting AES IV in the client side url

I shared the encryption and decryption function but I don't think it matters for this question. Scenario: https://example.com/posts/awtvwav1689at6awv697atve is hidden. So we have a query parameter, let's say password to be able access it. the id is…
KnowYourElements
  • 392
  • 1
  • 12
0
votes
0 answers

Inconsistent cypher result with bas64 output encode

I need to cypher a textual payload, save it somewhere and after a while read it and decypher it again. I started with some code and I noticed that there is an inconsistent behavior when I tell nodejs standard cypher to give me the output in base64.…
Elia
  • 1,417
  • 1
  • 18
  • 28
0
votes
0 answers

Encryption and decryption in node js

I am trying to encrypt and decrypt the values in node js but i am getting empty value as decrypt value , here is my code Encryption seems to be fine const encryptedWord = CryptoJS.enc.Utf8.parse('testing'); …
vellai durai
  • 1,019
  • 3
  • 16
  • 38
0
votes
0 answers

signature verification using node.js crypto and aws s3 returns error wrong tag

Trying to validate a signature of a file using Node.js Crypto. Not getting success. I'm new to Node.js. this openSSL works for me: openssl enc -d -A -base64 -in update.sig -out update.sha256 - that turns the sig into a binary openssl dgst -sha256…
bradmax
  • 11
  • 1
  • 3
0
votes
1 answer

Misformed armored text when loading Message from Stream Openpgp.js

I have a Job handling the execution of a decryption job in the background. This is the code for the decryption: export default async function ( job: Job, cb: DoneCallback, ) { console.log( `[${process.pid}] Attempting…
0
votes
0 answers

AOP implementation of return value decryption

demand:Decryption of database query results with AOP MybatisPlus Return results,for example:List I customize an annotation to intercept annotated methods, But I intercepted the method and got that the return type is List,How can I get the VO type in…
lzh_86
  • 1
0
votes
0 answers

when error comes my code not going in else block in node js

This is a simple encryption/Decryption Controller I want condition when encryption-decryption failed then run else block otherwise go with if Block work completely fine but when encryption-decryption failed else block not works console logging an…
Smit Gajera
  • 1,001
  • 1
  • 8
  • 26
0
votes
2 answers

Catch error while decrypting using crypto and node

I am trying to decrypt an encrypted text. If I provide the correct encrypted text, it works fine. But if I put the wrong encrypted text, the node app just crashes. No try catch block helps and no error is thrown. Any what can I do to catch the error…
Amarsh
  • 11,214
  • 18
  • 53
  • 78
0
votes
1 answer

Encrypting using Crypto in Node js throw error

I am trying to encrypt Credit Card data of customer to AES 256 CBC format but anytime I I call the API I get this error: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: ERR_INVALID_ARG_TYPE at ServerResponse.writeHead…
Olusanya Michael
  • 107
  • 2
  • 11
0
votes
1 answer

Node.js Crypto En- / Decrypting Buffer somehow decreases in size

I'm trying to encrypt a text using AES-256-CBC. For this I'm using the node.js crypto module. Now I'm having trouble understanding something. I convert my plainText into a buffer and want to pass it to the cipher that way. The buffer size of the…
db3000
  • 400
  • 5
  • 16