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

b64decode python vs Buffer.from(ePayload, 'base64') node JS

Encryption is done is python & decryption to be done in Node js but facing following issues in JS I guess some characters are getting escape from string within JS like 'backslash', '_', '' Expected - Python utf-8 string should match with Node JS…
2
votes
1 answer

Sequelize querying with encrypted fields using after* before* hooks

Hey there I have a question about the best way to store data encrypted in my database. I use Node.js, a MySQL database and sequelize 6.6.5 as ORM. Here's what I do: With beforeCreate and beforeUpdate hooks I'm encrypting my data before storing it…
db3000
  • 400
  • 5
  • 16
2
votes
2 answers

Question about signature verification using Cloud KMS

I'm trying to verify a signature generated with Google's cloud KMS, but I keep getting invalid responses. Here's how I'm testing it: const versionName = client.cryptoKeyVersionPath( projectId, locationId, keyRingId, keyId, …
2
votes
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,658
  • 2
  • 14
  • 19
2
votes
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
  • 365
  • 2
  • 11
2
votes
1 answer

WebCrypto API: DOMException: The provided data is too small

I want to decrypt a message on the client-side(react.js) using Web Crypto API which is encrypted on the back-end(node.js), however I ran into a weird problem and don't have any idea what is wrong(I also checked this) node.js function…
Shahin Ghasemi
  • 1,600
  • 1
  • 20
  • 38
2
votes
2 answers

How to generate random prime number?

I am currently working on a JavaScript team project which involves cryptography. I want my program to be as safe as possible, if possible industry-level safe, and as such I have been searching for community-approved implementations of random big…
Ignis Oculo
  • 71
  • 1
  • 5
2
votes
2 answers

AES256 Issue using swift 5

I am using AES256 algorithm CBC mode with pkc7 padding. I have backend in Node.js. But getting first 12 random characters. Here is my swift code: func encrypt(data: Data, key: Data, iv: Data) throws -> Data? { // Output buffer (with…
anshul king
  • 558
  • 4
  • 17
2
votes
2 answers

C# Rfc2898DeriveBytes to node

I'm rewriting an encryption algorithm (implemented in C#) using Node. The encryption uses a 32-byte key and a 16-byte IV and it uses Rfc2898DeriveBytes to generate the key and IV. I have used crypto.pbkdf2Sync to generate a key of 48 bytes instead…
Nagendra Varma
  • 2,215
  • 3
  • 17
  • 26
2
votes
0 answers

Encrypt large file with Asymmetric cryptography

i want to encrypt a file with public key in python, Asymmetric methode im really use cryptography biblio and PyCrypto but all algorithm encrypt short text not big file i need solution for my problem , in cryptography biblio i use hazmat module . i…
2
votes
1 answer

How to store iv used to create cipher in nodejs's createcipheriv, for future decryption?

I'm new to cryptography and I'm using nodejs to serve an app. My app uses config files that I want to encrypt them before production, and when nodejs server needs these files (in production) it will decrypt them. I'm using…
2
votes
1 answer

Speeding up AES decryption in Node js

I wanted to create web page on which would be displayed data, previously decrypted on server. On server in app.js all of data from one folder is read and then decrypted. var http = require('http'); var path = require('path'); var express =…
Stageflix
  • 31
  • 4
2
votes
3 answers

Getting error(Error: Unsupported state or unable to authenticate data) in nodejs decryption

I have encrypted a message using AES/GCM/NoPadding algorithm(AES-256) in java & trying to decrypt it in NodeJs. Getting exception "Error: Unsupported state or unable to authenticate data" while decryption. Below is the complete code of java and…
Paddy02
  • 71
  • 2
  • 11
2
votes
1 answer

Encrypt a string in nodejs and decrypt in java

I am encrypting a text in NODEJS and trying decrypt in Java but getting error. my nodejs code: var crypto = require('crypto') , key = 'mykey@91' , plaintext = 'SS18617710213463' , cipher = crypto.createCipher('aes-128-ecb', key) , decipher =…
Srinivas VK
  • 23
  • 1
  • 4
2
votes
1 answer

AES/CBC/PKCS5PADDING IV - Decryption from Java to NodeJs

I am trying to decrypt in NodeJs. It is working in Java. But I am not able to achieve same in Node. I am using node-version: 8.4 Please find my NodeJs code: var crypto = require('crypto'); function decryption (message, key) { var messageArray =…
Chaitanya Joshi
  • 304
  • 1
  • 4
  • 22