All Questions
Tagged with cryptography node.js
894 questions
-4
votes
0
answers
39
views
Is it possible to run javascript on client side when implementing a telegram bot? [closed]
Is it possible to run javascript on client side when implementing a telegram bot?
To be more specific, I want to generate key pair on client, but don't let the bot know the client private key, and use ...
0
votes
1
answer
40
views
HKDF function in Python and NodeJS give different results, why?
While working on implementing encryption/decryption between a Python backend server and a NodeJS frontend, my decryption attempts on the frontend were failing. I noticed that HKDF result generated by ...
0
votes
0
answers
16
views
Getting error while trying to generate wtns file in ZKP
Actullay I was trying to generate a witness file in a zero knowledge project. Here is my circom code
pragma circom 2.0.0;
include "./node_modules/circomlib/circuits/poseidon.circom";
...
1
vote
0
answers
117
views
Validating a Shopify Webhook
In Shopify, webhooks can be created for certain events that take place in the admin such as updating a product and they provide a note that says:
Your webhooks will be signed with
...
5
votes
1
answer
137
views
How to decrypt C++ OpenSSL ChaCha20 from nodeJS?
I'm trying to decrypt data that have been encrypted using C++ OpenSSL ChaCha20 from Node.js, but standard Node.js crypto module doesn't directly support ChaCha20 without Poly1305.
I have tried using ...
1
vote
0
answers
131
views
Telegram WebApp hash verification mismatch despite correct data and bot token in Node.js
Issue:
I'm trying to verify the integrity of the hash provided by the Telegram WebApp authentication flow using Node.js, but the calculated hash never matches the provided hash. I'm using the correct ...
1
vote
1
answer
173
views
Disable FIPS for NodeJS build
I am running into the following problem when building NodeJS app on a FIPS-enabled RHEL8 server. The command is CI=false npm run build
Error: error:060800C8:digital envelope routines:EVP_DigestInit_ex:...
0
votes
0
answers
76
views
Signing XML and validating it returns invalid signature
I'm using xml-crypto to sign an XML document in order to communicate with an API.
This is the code that I use to sign it (it's pretty close to the tutorial in the readme file of the library).
var sig =...
0
votes
0
answers
54
views
Different hash output from crypto.pbkdf2Sync between Node.js 16.x and 20.x
I'm using the crypto.pbkdf2Sync function to generate a hash, but I'm getting different results between Node.js version 16.x and 20.x.
Here's my code:
const crypto = require('crypto');
const user = { ...
0
votes
1
answer
55
views
How to encrypt in nodejs via AES-256-CBC to be consistent with openssl
I used to encrypt text in nodejs by invoking openssl via execSync, but it's a bad practice, because it could leak password to system logs. Now I want to use the crypto library, but I get inconsistent ...
0
votes
1
answer
104
views
Trouble importing RSA-PSS key in NodeJS using subtle.importKey
I'm trying to import a private key to sign an XML file in NodeJS.
To sign the XML, I'm using xmldsigjs which requires the key to be passed in a CryptoKey object that is obtained by crypto.subtle....
0
votes
1
answer
68
views
How to verify MSSQL signbycert in NodeJS
I'm not familiar with cryptography or the PKCS protocol,
but what i need is to crypto.verify succesfully in NodeJS using singature generated in MSSQL signbycert.
by using this as reference: https://...
0
votes
1
answer
1k
views
How to encrypt decrypt with Node.js crypto module?
I'm trying to encrypt and decrypt text using the 'aes-256-cbc' algorithm and using URL safe encoding. Here's what code I've managed to write so far.
import crypto from 'node:crypto';
function encrypt(...
0
votes
1
answer
116
views
Why Am I Getting Different Cipher Outputs Between Node.js and PHP When Reading Large Files by Chunks?
Inconsistent Cipher Output Between Node.js and PHP When Reading Large Files by Chunks
Problem Description
I'm facing an issue with ensuring consistent cipher output between Node.js and PHP when ...
0
votes
0
answers
42
views
web3 and etherscan api getTransactionCount for nonce returning 0
const propagateAddress = "0xd6616Cf7F133F0c00E2712718B8133c20E3F6605"
const web3 = new Web3("https://rpc2.sepolia.org");
var nonce = await web3.eth.getTransactionCount(...
0
votes
1
answer
438
views
Implementing encryption/decryption in Typescript using Web Crypto API
I'm having a security requirement not to send data as plain-text to the server and the credentials shouldn't be visible in the network tab of the browser. I could have used hashing but the catch is we ...
0
votes
1
answer
88
views
Discrepancy between nodejs crypto module and tweetnacl.js output
For example, I have this code in nodejs:
import crypto from 'crypto';
const pkey = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIJC52rh4PVHgA/4p20mFhiaQ/iKtmr/XJWMtqAmdTaFw
-----END PRIVATE KEY---...
1
vote
0
answers
304
views
Lemonsqueezy webhook x-signature returns invalid every time
I'm doing an integration of my app with Lemonsqueezy and use webhook to get data about subscriptions. I use everything from LS official guides, however I receive invalid x-signature used to validate ...
0
votes
0
answers
65
views
How to recreate Bob and Alice Non-Interactive Diffie-Hellman Key-Exchange?
I'm trying to recreate the Bob and Alice Diffie-Hellman Key Exchange, since I'm doing my first steps in cryptography and cyber security.
The goal is to implement a non-interactive version of this ...
1
vote
0
answers
114
views
How can I parse signature value and algorithm from my certificate?
const cert = new crypto.X509Certificate(certificatePem);
// Extract the signature algorithm and signature value from the certificate
const signatureAlgorithm = cert.signatureAlgorithm;
const ...
1
vote
0
answers
295
views
How to implement E2E encryption in a multi-user app?
I'm running an SaaS application with support for multiple tenants. Each tenant can have multiple users assigned. Those users collaborate on a database of documents that's owned by the tenant. With my ...
0
votes
0
answers
94
views
Node.js AES decryption code converted to Golang throws key size error
I have a nodesJS code which is used for decrypting and works fine. I was trying to convert the same in to Golang it always throws "panic: crypto/aes: invalid key size 7" error, which works ...
0
votes
1
answer
454
views
crypto.subtle unable to decrypt, iv isn't ArrayBuffer, encrypted data is undefined
I'm trying encrypt files and upload them to the cloud and decrypt them locally with Node.js v21.6.2. Unfortunately, I'm having trouble getting the decrypt to work. I'm able to generate a key and ...
1
vote
1
answer
320
views
Is it possible to migrate from bcrypt to crypto?
Having multiple ACL with user records and password generated with.
bcrypt.hashSync(request.password, bcrypt.genSaltSync(8))
We can compareSync these passwords without the need to generate the salt ...
0
votes
1
answer
440
views
Generating a random key using AES 256(AES/ECB/PKCS5Padding) algorithm
// import the path module
const path = require('node:path');
const crypto = require('crypto');
// get the public key certificate
const CRTpath = path.basename('./PublicKey.crt');
const GenKey = ...
0
votes
1
answer
238
views
Sign XML with xml-crypto and getPeerCertificate
I am using NodeJS 20.11.1 and Express to create a HTTPS server that would have a route /cert. The idea is that this route will request the client certificate that will be used to sign a document. The ...
0
votes
0
answers
85
views
Decryption with Node.js crypto module does not result in the encrypted text
I am using AES-256-CFB encryption method to encrypt text but when decrypting using the same parameters it doesn't give the text I encrypted
Code used to encrypt
const ss = Buffer.from(decipher.update(...
0
votes
2
answers
347
views
How parse a Certificate Signing Request (CSR) file with Javascript to get the subject?
I read a Certificate Signing Request in X.509 format. I have tried to parse it with the class X509Certificate from NodeJS 'crypto' library.
The input format is a string
-----BEGIN CERTIFICATE REQUEST--...
1
vote
1
answer
3k
views
crypto.subtle is undefined even though I'm using http://localhost:3000
I'm trying to use crypto.subtle.digest() as part of a checksum function for a file upload project I'm working on but for some reason I keep getting the following error:
upload-form.tsx:129 Uncaught ...
1
vote
1
answer
674
views
How to pipe file read stream to compute sha256 hash and write to write stream at same time in Node.js?
How do you both compute the sha256 hash of a read stream in Node.js, and write to a write stream for it? I am going to use this to name a file after its sha256 hash, first giving the file a temporary ...
-2
votes
1
answer
361
views
Node.js can not use crypto as a function
const { hashGen } = require('crypto');
var hash = hashGen('sha256').update(hash).digest('hex');
I am being given the error:
TypeError: hashGen is not a function
I tried to create a password with a ...
1
vote
1
answer
49
views
Node pre 'save' hook using a statics function
I'm trying to use a custom encrypt function inside a pre 'save' hook on my schema, but i'm having an error telling me that this.encrypt is not a function
passwordSchema.pre('save', async function() {
...
0
votes
1
answer
1k
views
AES-GCM 256 encryption and decryption using nodejs and java
In an application I want the java frontend should take the encrypted text from nodejs and provided a fixed SECRET_KEY it should be able to decode it and the vice versa. Any help is appriciated.
I am ...
2
votes
0
answers
465
views
Detect crypto payment (USDT TRC20)
My problem is that I am not getting an event about my transaction when tracking a smart contract. In my code below is an example of my WalletService class in which I create an instance of new TronWeb(....
0
votes
1
answer
119
views
Rewrite JwkThumbprint getter function from node-jose to C#
There is a function in NodeJs that, using node-jose, gets a thumbprint from a certificate.
const jose = require('node-jose');
generateJwkThumbprint = async (jwk) => {
let jwkKey = await jose.JWK....
0
votes
1
answer
252
views
Node encrypt with forge-node and bouncyCastle decryp
I currently generate a key pair and then encrypt the private key with a paraphase as you can see in the following code in node with the node-forge library.
const keypair = forge.pki.rsa....
0
votes
2
answers
297
views
Cannot decipher some encrypted text using CryptoJS
I am encrypting a set of data in the following way:
const dataToEncrypt = `${userId}-${unixTime}`;
const encryptedData = CryptoJS.AES.encrypt(dataToEncrypt, CryptoJS.enc.Utf8.parse("4v7KVa1U_>...
1
vote
1
answer
94
views
Incorrect NodeJS Crypto Hash when using ReadableStream.pipe
I tried calculate the sha256 hash in 2 different ways, only one of which gave the correct result.
import { createHash } from 'node:crypto';
import { Readable } from 'node:stream';
function f1(info: ...
1
vote
3
answers
2k
views
WhatsApp Flows Decryption Error - error:02000079:rsa routines::oaep decoding error
I have utilized the WhatsApp Flows API to integrate flows into our application. When publishing the flow, I need to decrypt it using the following structure:
{
encrypted_flow_data: "<...
0
votes
0
answers
2k
views
Bad encrypt with NextJS
I have a client with NextJS and an API with Python. I have tried to encrypt information with the client and decrypt it with the API.
I have a script with NodeJS to test the encryption, and then I ...
0
votes
1
answer
1k
views
Question about AES encryption library "crypto-js" in Node.JS
Here is my sample code
const CryptoJS = require('crypto-js')
const plaintext = "hello world"
const passphrase = "my_passphrase"
const encrypted = CryptoJS.AES.encrypt(plaintext, ...
1
vote
0
answers
4k
views
NodeJS Crypto throws "Error: error:1C80006B:Provider routines::wrong final block length"
I am running a MERN app where I store encrypted user data. When retreiving the data, the data should be decrypted.
This is the code that I use for encrypting and decrypting the data
const crypto = ...
1
vote
1
answer
393
views
WhatsApp FLows - Could not decrypt the response received from the server in node js. Getting error RangeError: Invalid key length
I am trying to decrypt to below json with node js code where i am getting invalid key length error crypto.createDecipheriv
{
"encrypted_flow_data": "EfdsCol+ZQMdkWYaa+...
0
votes
0
answers
63
views
error:0409A06E:rsa routines:RSA_padding_add_PKCS1_OAEP_mgf1:data too large for key size
I have JWT token and I want to decrypt it in Node/Express app using crypto module using public/private RSA keys.
encrypt.js
const encrypt = (plainText) => {
const cipherText = crypto....
0
votes
0
answers
260
views
Hybrid encryption of RSA with AES is working yet it fails randomly at times
I have a java backend application that serves jsp for the frontend. This application has several form pages. On submission of a form, the frontend form data would be encrypted with aes 256 gcm and the ...
0
votes
1
answer
2k
views
How can I derive a key pair from mnemonic phrase successfully in NodeJS?
I'm trying to create a simple cryptocurrency for which I made a wallet in Node.JS using the bip39 and crypto module. The plan is to be able to create a wallet so that the script generates a random ...
0
votes
0
answers
369
views
AES-GCM JavaScript Implementation
I'm trying to write a javascript method which can decrypt the cipher text using AES-GCM 128bit key. I was able to write a java method, but facing some issues with the js code. Tried a lot, but couldn'...
2
votes
1
answer
538
views
aes256-wrap Error 'ERR_CRYPTO_INVALID_IV' But AES-KW Does Not Require An Initialization Vector?
MDN mentions that:
AES-KW does not require an initialization vector (iv)
But when I try and encrypt my content encryption key (CEK) using the key encryption key (KEK) like below Node.js Crypto ...
0
votes
0
answers
595
views
NodeJS- Crypto.publicEncrypt() with cert public key gives "EVP_PKEY_encrypt_init:operation not supported for this keytype"
Using NodeJS v16/v17, I am trying to encrypt a data with Crypto.publicEncrypt() using a certificate public key(pem). Code snippet is added below:
const pkey = '-----BEGIN CERTIFICATE-----
<...
0
votes
0
answers
462
views
Is it okay to concatenate iv and auth tag along with token created using aes-256-gcm?
I'm generating an access token for users and saving it in the user's browser cookie, i'm wondering if making iv and auth tag public like this is safe or not?
When i create a token i make it like iv....