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

Why crypto.createHash() is not writable until setEncoding() is called?

I use request package with crypto. It seems that request implements legacy stream protocol and don't write any data to the piped destination until it's writable. Stream.prototype.pipe = function(dest, options) { var source = this; function…
Ivan Velichko
  • 6,348
  • 6
  • 44
  • 90
0
votes
0 answers

How to decrypt cipher text message in using xor without key in java

I am given 11 ciphertext which I am able to use to get the key, I need to achieve the plain text of the 11th ciphertext. i first xor each of the 1-10 ciphertext with the 11th cipher text, then xor each of these results with the key word i am trying…
ProgramER
  • 11
  • 5
0
votes
1 answer

Node.js v6.2.2 crypto.createCipheriv "Invalid key length" Error

Below is the source for multipassify. The code works perfectly below Node 6 and gives an error onward. The error looks like this: crypto.js:184 this._handle.initiv(cipher, toBuf(key), toBuf(iv)); ^ Error: Invalid key length at…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
0
votes
1 answer

Node.js crypto.pbkdf2Sync password does not match with python script

I have a mongodb server that stores password generated by this node.js code: encryptPassword(password, callback) { if (!password || !this.salt) { return null; } var defaultIterations = 10000; var defaultKeyLength = 64; var salt…
hasmet
  • 758
  • 3
  • 13
  • 32
0
votes
1 answer

LockBox / Node Crypto compatibility

I'm trying (and failing) to decipher in Delphi usung LockBox 3 a message that was encrypted using Node.js' crypto library. node.js code: var crypto = require('crypto'); var cipher = crypto.createCipher('aes-256-ctr', 'my password'); var crypted =…
Z .
  • 12,657
  • 1
  • 31
  • 56
0
votes
0 answers

HMAC Digest node.js crypto

Can anyone help me with this problem please. I am trying to use the follwing code to generate a HMAC digest, but crypto module in node doesnt appear to return the correct signature? var ipnStr =…
rjmacarthy
  • 2,164
  • 1
  • 13
  • 22
0
votes
1 answer

Node.js crypto aes-256-cbc-hmac-sha1 doesn't work

I'm trying to use the aes-256-cbc-hmac-sha1 algorithm with the Node.js crypto module. Here's a code snippet showing what I'm trying to do: // adapted from http://stackoverflow.com/a/6046913 var crypto = require('crypto'); var data = "I am the clear…
thebuckst0p
  • 544
  • 1
  • 5
  • 13
0
votes
1 answer

Problems when using AES crypto between Python and Node

I want to encrypt a string with python (aes-128-ecb), and decrypt the string with node. Below is what I wrote. I don't know why it doesn't work. The PyCrypto lib doc: http://pythonhosted.org//pycrypto/ The node crypto lib doc:…
Yad Smood
  • 2,752
  • 2
  • 24
  • 37
0
votes
1 answer

NodeJs Crypto error -Object has no method pbkdf2Sync

I am using nodeJS Crypto Module to encrypt password. Sample code: crypto.pbkdf2Sync(password, salt, 200, 64).toString('base64'); But I am not sure, whenever I call this method, following error shown TypeError: Object # has no method…
niran
  • 1,920
  • 8
  • 34
  • 60
0
votes
2 answers

Node.js Crypto cipher special characeters

I am trying to field level encrypt data in Node using the crypto library. It seems to work just fine, except with special characters like $ and - Ex "Price-Smith" Not sure why function encrypt(data, key) { if (data === null) return null …
Andrew Madonna
  • 155
  • 5
  • 12
0
votes
1 answer

node.js crypto streams not giving output

I am struggling to understand what I am doing wrong here. I am trying to write something to encrypt data coming in and out of a TCP socket but I am struggling to get any output from the crypto cipher stream. Example: (Stripped down to keep it as…
James Sefton
  • 133
  • 9
0
votes
1 answer

Node.js crypto module

I am trying to implement encryption in node.js using the crypto module. Below is a snippet of my code: var SECRET_KEY = "RANDOMKEY"; var crypto = require("crypto"); var MD5 = crypto.createHash("MD5"); MD5.update(SECRET_KEY, 'ucs2'); var hash =…
nimgrg
  • 582
  • 1
  • 7
  • 17
0
votes
2 answers

Crypto module - Node.js

Which is the simplest way to compare a hash of a file without storing it in a database? For example: var filename = __dirname + '/../public/index.html'; var shasum = crypto.createHash('sha1'); var s = fs.ReadStream(filename); s.on('data',…
giokokos
  • 602
  • 1
  • 6
  • 20
0
votes
1 answer

how to use nodejs crypto module in javascript

Is there any way i can use nodejs "crypto" module in javascript without actually using node. Or is there any similar javascript library that does all the things that "crypto" does Like i neeed the below code in javascript with the help of nodejs …
Amit
  • 6,839
  • 21
  • 56
  • 90
-1
votes
1 answer

Implementing DES encryption in NodeJS (Crypto)

I'm trying to convert the below java function for DES encryption into NodeJS. public static String decrypt (String value) { PBEParameterSpec pbeParamSpec = new PBEParameterSpec(SALT, COUNT); PBEKeySpec pbeKeySpec = new PBEKeySpec(KEY); …
niyasc
  • 4,440
  • 1
  • 23
  • 50
1 2 3
14
15