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

How to write Java code for AES GCM Decryption using authentication tags

I am building a Java SDK for which I need to write a service to decrypt cipher text using initialVector, authenticationTag and secretKey. I am taking reference from equivalent node SDK. The JavaScript code is as follows using the crypt package of…
thatman
  • 333
  • 3
  • 14
0
votes
1 answer

I tried many methods for decipher but none of them worked

I need to encrypt and decrypt files for the application I am developing. I also use Node.js' built-in crypto package for this. When I try in variables, I can encrypt/decrypt a text, but whenever it's time to encrypt/decrypt files, decipher causes…
Fatih EGE
  • 15
  • 3
0
votes
0 answers

Downloading the file from the cloud by entering the name of the file through my graphical interface

My project is to develop a Python application that allows users to encrypt their client-side data and store it securely on my university's NextCloud collaboration system via WebDAV. I have a problem in the decryption part, I want the file to be…
0
votes
1 answer

How can I create and view passwords securely with encryption in Python using Fernet and base64 libraries?

from cryptography.fernet import Fernet import base64 #def write_key(): #key=Fernet.generate_key() #with open("key.key","wb") as key_file: #key_file.write(key) #write_key() def load_key(): file=open("key.key", "rb") …
victor
  • 1
  • 1
0
votes
0 answers

how to decrypt a message with crypto.pbkdf2

i cant find a way decrypt a message using crypto library im using a service that encrypts messages using the following logic (its not my service, i cant change the encryption function), after a very long search i couldn't find a way to decrypt it, i…
alal
  • 1
0
votes
0 answers

getting TypeError: Invalid initialization vector while using crypto module in js

this[kHandle].initiv(cipher, credential, iv, authTagLength); ^ TypeError: Invalid initialization vector at Cipheriv.createCipherBase (node:internal/crypto/cipher:122:19) at Cipheriv.createCipherWithIV…
0
votes
0 answers

How can i load a EC key pem from file using the crypto ECDH module in node?

When i load the ECDH private key with the crypto module i am getting the following error: node:internal/crypto/diffiehellman:231 this[kHandle].setPrivateKey(key); ^ RangeError: Private key is not valid for specified curve. at…
0
votes
0 answers

Converting java cipher crypto code to node js crypto

I have a encryption/decryption functionality in java code and wanted to write the same logic using the crypto node-js library. What's the equivalent of these Java codes ? Java code : String iv = "Some random string"; AlgorithmParameterSpec…
Madhav mishra
  • 313
  • 4
  • 20
0
votes
0 answers

How to convert raw EC key to PKCS8 without node:crypto export function

I need to convert raw EC key to pkcs8 and vice versa. I am using react-native-quick-crypto as a replacement for node:crypto. sadly, it does not include node's crypto.createPrivateKey(...).export(...) function so I am unable to use it co convert my…
David Novák
  • 1,455
  • 2
  • 18
  • 30
0
votes
0 answers

What type of encryption are they using?

recently I've been working with JavaServerPager (JSP), there is a form that queries data from a database, but the data is returned encrypted, I have tried some methods to decrypt, but it seems that they are not the correct ones, here are some plain…
0
votes
1 answer

Imported a public RSA key into nodejs

I am trying to transfer a public RSA key generated in swift into my Nodejs server. I generated the RSA key using the following code. private var clientPriv: SecKey? private var clientPub: SecKey? private init(){ let params: [String: Any] = [ …
0
votes
1 answer

Signing signature in Node JS and verifying it on PHP

I have this working example, whereby I have created private key and public key on PHP. The below code works fine & signature is valid WHEN i am using pure php. However, the idea is to generate signature with Javscript and then validate the…
desh
  • 627
  • 1
  • 7
  • 19
0
votes
0 answers

Is it possible to ECDSA verify hash of the message instead of plain message with nodejs crypto module?

I know I can verify plain message with following code: const verify = crypto.createVerify('sha256') verify.write(Buffer.from(message, 'base64')) verify.end() const verified = verify.verify(publicKey, signatureToVerify, 'base64') But I need to…
David Novák
  • 1,455
  • 2
  • 18
  • 30
0
votes
0 answers

I have generated ECDSA signature with nodeJS crypto library. How to verify it with openssl command

I have generated ECDSA-with-sha256 signature in node using following script: const crypto = require('node:crypto') const keys = { "pubKey":…
David Novák
  • 1,455
  • 2
  • 18
  • 30
0
votes
0 answers

MongoServerError: BSON field 'insert.jsonSchema' is an unknown field

I am new in MongoDB. I want to do client side field level encryption. Here is the full project link which one I am…