h2non / jshashes

Fast and dependency-free cryptographic hashing library for node.js and browsers (supports MD5, SHA1, SHA256, SHA512, RIPEMD, HMAC)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'any' encofing fails

jeremiehuchet opened this issue · comments

I'm executing:

new Hashes.SHA256().any('test', "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./")

which give me A-*A_[Hza*ek.e]hlq*%VwLgH0zDi-?4);_0tbQk,
but I'm expecting something like -*A_[Hza*ek.e]hlq*%VwLgH0zDi-?4);_0tbQk\, without the A prefix.

I'm not sure I'm expecting the right result, but I observed a lot of outputs beginning with the first character of my encoding (A).

Using SHA1, the result seems to be OK, but I'm suspecting the same issue appears with MD5 and SHA512.

I made some additional tests, I think the issue depends on the amount of characters set in the encoding.

SHA256 using an encoding of 82 characters:

new Hashes.SHA256().any('test', 'Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

results in AaaaaaaaaaaaaAaaaaaaaaaaaaaaaaaaaaaaaaaaa
but I'm expecting aaaaaaaaaaaaAaaaaaaaaaaaaaaaaaaaaaaaaaaaa

This issue seems to happen also with SHA1:

new Hashes.SHA1().any('test', 'Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

results in Aaaaaaaaaaaaaaaaaaaaaaaaaa
but I'm expecting aaaaaaaaaaaaaaaaaaaaaaaaaa

@jeremiehuchet has this issue been fixed and can therefore be closed?

@h2non IMHO this issue should be closed as it has been fixed long time ago...

You are right,
I am sorry I didn't replied. I thought I can find some time to attempt to reproduce the issue or confirm it is solved.