node-crypto

nodejs crypto module vs crypto-js

感情迁移 提交于 2019-12-22 05:32:07
问题 I'm quite new to NodeJs and trying to figure out how to use the "crypto" module. While playing around with it I notice the difference between the "crypto" module in NodeJs and crypto-js: With crypto-js, I have: function SHA256Hash(password, salt, iteration) { var saltedpassword = salt + password; var sha256 = CryptoJS.algo.SHA256.create(); for(var i = 0; i < iteration; i++) { alert("saltedpassword = " + saltedpassword); sha256.update(saltedpassword); var saltedpassword = sha256.finalize();

crypto createHMAC output differs according to nodejs version

自作多情 提交于 2019-12-21 19:58:25
问题 I have issues with crypto module while upgrading my node version. The created HMAC depends on the version of node. You'll find below the piece of code that reproduces the problem. If I encode my key as BASE64 (or any) the HMAC does not depends on node.js version. If I encode it as binary, the HMAC is different if I change my node.js version. [EDIT] according to Why crypto.createHash returns different output in new version? I have added the encoding when calling the update function code

EVP_DecryptFinal_ex:bad decrypt when using Node.js

允我心安 提交于 2019-12-21 09:25:32
问题 Using the following node js: var crypto = require('crypto'); var encrypt = function (input, password, callback) { var m = crypto.createHash('md5'); m.update(password); var key = m.digest('hex'); m = crypto.createHash('md5'); m.update(password + key); var iv = m.digest('hex'); console.log(iv); var data = new Buffer(input, 'utf8').toString('binary'); var cipher = crypto.createCipheriv('aes-256-cbc', key, iv.slice(0,16)); var encrypted = cipher.update(data, 'binary') + cipher.final('binary');

Node JS crypto, cannot create hmac on chars with accents

情到浓时终转凉″ 提交于 2019-12-18 19:49:43
问题 I am having an issue generating the correct signature in NodeJS (using crypto.js) when the text I am trying to encrypt has accented characters (such as ä,ï,ë) generateSignature = function (str, secKey) { var hmac = crypto.createHmac('sha1', secKey); var sig = hmac.update(str).digest('hex'); return sig; }; This function will return the correct HMAC signature if 'str' contains no accented characters (chars such as ä,ï,ë). If there are accented chars present in the text, it will not return the

Node 'crypto' SHA256 hashing model behaving erratically

佐手、 提交于 2019-12-13 03:34:54
问题 I have a function that takes a file and finds its SHA256 hash. Each time I resubmit a file, it produces a different hash for the same file. On the first submission, it produces the correct hash. Each re-submission produces an incorrect hash. If I re-submit the same files in the same order, they all produce the same (incorrect) hash. I think that the buffer might be building up. Or maybe something else? I'm trying to figure out how to clear the buffer array. Any ideas? import React, {

HMAC changes according to node version (paybox module)

冷暖自知 提交于 2019-12-12 04:04:55
问题 I am using https://www.npmjs.com/package/paybox and I need to upgrade my node version (from 5.6 to 6+) As you can see below, the generateHMAC creates a hash that differs if I change my version of node. Can you help me understand this, and tell me if it can compromise something (maybe it is OK? several hashes could be OK?) Here is my code snippet: "use strict"; const paybox = require('./node_modules/paybox/lib/paybox.js') let computed_hmac = paybox.generateHMAC({a:12},

How to verify file using rsa public key

纵然是瞬间 提交于 2019-12-11 07:48:44
问题 I base my work on this answer I'm trying to verify a file using a public key. Here is my code: var hash = crypto.createHash("sha256"); hash.setEncoding("hex"); var fd = fs.createReadStream("path/to/my/file"); fd.on("end", function() { hash.end(); var fileHash = hash.read(); const publicKey = fs.readFileSync('keys/public_key.pem'); const verifier = crypto.createVerify('RSA-SHA256'); const testSignature = verifier.verify(publicKey, fileSignature, 'base64'); console.log("testSignature: \n" +

Nodejs crypto vs python hashlib

北城余情 提交于 2019-12-07 12:21:00
问题 I'm trying to make a python function and a nodejs function compute the same hash. However, it seems like the binary that is outputted is different between nodejs crypto and python hashlib. The python I'm using is: hash = hashlib.sha512() hash.update(salt) hash.update(password.encode('utf8')) hash.digest() The node/coffeescript is: crypto.createHash('sha512').update(salt, 'binary').update(password, 'utf8').digest() These lines should produce the same result, but for some reason they don't.

nodejs crypto module vs crypto-js

陌路散爱 提交于 2019-12-05 06:23:04
I'm quite new to NodeJs and trying to figure out how to use the "crypto" module. While playing around with it I notice the difference between the "crypto" module in NodeJs and crypto-js: With crypto-js, I have: function SHA256Hash(password, salt, iteration) { var saltedpassword = salt + password; var sha256 = CryptoJS.algo.SHA256.create(); for(var i = 0; i < iteration; i++) { alert("saltedpassword = " + saltedpassword); sha256.update(saltedpassword); var saltedpassword = sha256.finalize(); sha256.reset(); } return saltedpassword.toString(CryptoJS.enc.Base64); } Then call : var hashedPassword =

crypto createHMAC output differs according to nodejs version

情到浓时终转凉″ 提交于 2019-12-04 11:29:55
I have issues with crypto module while upgrading my node version. The created HMAC depends on the version of node. You'll find below the piece of code that reproduces the problem. If I encode my key as BASE64 (or any) the HMAC does not depends on node.js version. If I encode it as binary, the HMAC is different if I change my node.js version. [EDIT] according to Why crypto.createHash returns different output in new version? I have added the encoding when calling the update function code snippet "use strict"; const crypto = require('crypto'); console.log(process.version); let key =