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

160 questions
0
votes
1 answer

Crypto module is not working with latest node 7.10

The following code snippet is working in Node 0.12.18 (replace Buffer.from to new Buffer) but it's not working with the latest Node version (7.10.0) Can anybody explain me why this is happening?? Anything is missing in below code. /* Node.js…
Manish Trivedi
  • 3,165
  • 4
  • 21
  • 27
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
  • 5,581
  • 3
  • 35
  • 72
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
  • 4
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
  • 42,912
  • 63
  • 199
  • 343
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
  • 678
  • 3
  • 10
  • 30
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. Danev
  • 11,848
  • 1
  • 29
  • 48
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 =…
Richard Macarthy
  • 2,115
  • 1
  • 12
  • 21
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
  • 534
  • 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,224
  • 1
  • 21
  • 33
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,682
  • 7
  • 27
  • 52
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
  • 135
  • 5
  • 11
0
votes
2 answers

Node js crypto sign returns empty string

I am wanting to sign a string with a private key using crypto. The sign method returns an empty string, I was hoping to get a signiture. var crypto = require('crypto'); var message = "This is a string I want to ensure is not tampered with."; var…
bluelightzero
  • 23
  • 1
  • 7
0
votes
0 answers

how to enable crypto in node js

I am including crypto module in node.js, but its methods are not accessible var crypto = require("crypto"); exports.testSHA = function(req,res) { var shasum = crypto.createHash('sha1'); } on createHash it says Unresolved function or method…
JN_newbie
  • 2,760
  • 8
  • 45
  • 79
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
  • 8
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
  • 572
  • 1
  • 6
  • 17
1 2 3
10
11