Comments (6)
Sorry, but I don't understand where this is an issue.
so that i'm not getting the result i'm expecting
Could you give me an example with the exact results you get and the ones you are expecting?
from node-md5.
var md5 = require('./../../lib/MD5/');
describe('test md5', function () {
it('should produce binary', function () {
var hash1, hash2, hash3
hash1 = md5('abc', {asString: true});
hash2 = md5(hash1 + 'a', {asString: true});
hash3 = md5(hash1 + 'a');
console.log('hash1', hash1);
console.log('hash2', hash2);
console.log('hash3', hash3);
//current code using utf8 on message
//output is:
//hash1 �P�<ÒO°Ö�?}(ár
//hash2 =ªÙmeÐñY��ìj^X-û
//hash3 3daad96d65d0f159988fec6a5e582dfb
//expected output is: (since the hash1 is a string with binary encoding, hash2 and hash3 should honor that encoding)
//hash1 �P�<ÒO°Ö�?}(ár
//hash2 Å(OQä®Æ8Ái
//hash3 131f0ac52813044f5110e4aec638c169
});
});
from node-md5.
But hash1 + 'a'
results in '�P�<ÒO°Ö�?}(ára'
, doesn't it? And that is hashed correctly.
I cannot change JavaScript's handling of strings.
from node-md5.
nope - for the current md5 module hash1 + 'a' results in "=ªÙmeÐñY��ìj^X-û" whereas below the hash1 + 'a' results in "Å(OQä®Æ8Ái". Basically, the current MD5 module does not give the option of using a binary encoded string in the message. It always processes the string as UTF8 but will output it as a binary string if you pass the option.asString=true. (Just seems inconsistent).
I'm hoping you can give an option as to what encoding to use for the string message.
Thanks.
Here's a sample code using node's basic crypto where I expect hash2 as "Å(OQä®Æ8Ái"
Code:
var crypto = require('crypto');
describe('test md5 crypto', function () {
it('should produce binary', function () {
var md5, hash1, hash2, hash3
md5 = crypto.createHash('md5');
md5.update('abc', 'binary');
hash1 = md5.digest('binary');
md5 = crypto.createHash('md5');
md5.update(hash1 + 'a', 'binary');
hash2 = md5.digest('binary');
md5 = crypto.createHash('md5');
md5.update(hash1 + 'a', 'binary');
hash3 = md5.digest('hex');
console.log('hash1', hash1);
console.log('hash2', hash2);
console.log('hash3', hash3);
//hash1 �P�<ÒO°Ö�?}(ár
//hash2 Å(OQä®Æ8Ái
//hash3 131f0ac52813044f5110e4aec638c169
});
});
from node-md5.
Okay, I get your point.
You can send me a pull request that implements this, if you really need such a feature in this module. Otherwise use crypto instead.
from node-md5.
resolved by #7
from node-md5.
Related Issues (20)
- dist folder not contained in npm package HOT 1
- If an Array of non-integers is mistakenly passed in, do not silently hash [0] HOT 3
- Passing url object gives unexpected results HOT 3
- when I installed with npm, `let` is used in md5.js. HOT 3
- md5 of blob HOT 2
- Incorrect result for ArrayBuffer HOT 7
- NPM module not in sync with git repo HOT 2
- docs for options HOT 2
- Is ES6 import possible? HOT 4
- When using MD5 to encrypt numbers, the results are inconsistent HOT 7
- Error: Illegal argument undefined at module.exports HOT 1
- get wrong answer for md5 encryption HOT 3
- How do you output the 16 length MD5 values? HOT 1
- Why should dist/md5.min.js be made uppercase?
- how to use it with new import syntax? HOT 4
- How to reverse hashed MD5 HOT 1
- Error 403 HOT 1
- Slow performance on large video files
- hashed value coming differntly
- Different results between int and String HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-md5.