Giter Site home page Giter Site logo

2 rounds error? about jssha HOT 7 CLOSED

caligatio avatar caligatio commented on May 30, 2024
2 rounds error?

from jssha.

Comments (7)

NobleUplift avatar NobleUplift commented on May 30, 2024

Can you show your code?

from jssha.

boinggg avatar boinggg commented on May 30, 2024

I'm just copy and pasting in the demo.
On Mar 18, 2014 6:59 AM, "NobleUplift" [email protected] wrote:

Can you show your code?


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-37935153
.

from jssha.

NobleUplift avatar NobleUplift commented on May 30, 2024

If you compute a hash and copy it back into the input field, it will result in a different result than rounds of hashing. This is because the data is finalized to give you that hash value, so you aren't taking a hash and doing another round of iteration on it; you are taking what jsSHA believes is just a string and hashing it. Actually, if you did hash, finalize, rehash, finalize, etc., it puts a huge load on the JavaScript engine and won't make it past 1000 rounds.

from jssha.

boinggg avatar boinggg commented on May 30, 2024

Oh is this normal? I'm pretty sure other places do it my way? Which is
slower but "universal"?
On Mar 18, 2014 7:31 AM, "NobleUplift" [email protected] wrote:

If you compute a hash and copy it back into the input field, it will
result in a different result than rounds of hashing. This is because the
data is finalized to give you that hash value, so you aren't taking a hash
and doing another round of iteration on it; you are taking what jsSHA
believes is just a string and hashing it. Actually, if you did hash,
finalize, rehash, finalize, etc., it puts a huge load on the JavaScript
engine and won't make it past 1000 rounds.


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-37938917
.

from jssha.

Caligatio avatar Caligatio commented on May 30, 2024

Noble got the explanation 99.9% correct. The issue is I don't believe you're dealing with your first round output correctly.

Round 1
Input -> ASCII string of test (74657374 in hex)
Output -> A hex encoded string of ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff

Your Round 2
Input -> ASCII string of ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff (6565323662306464346166376537343961613161386565336331306165393932336636313839383037373265343733663838313961356434393430653064623237616331383566386130653164356638346638386263383837666436376231343337333263333034636335666139616438653666353766353030323861386666 in hex)
Output -> 5797448d5c775085bc82b808b9d01bb4ef795dfd05ea377d9b537d5e3495179f0b0c03f372518209db3dfbdae47c8529412ce9154dd1c5b99932cdf3b079c125

My Round 2
Input -> hex string of ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
Output -> faadcaf60afd35dfcdb5e9ea0d0a0531f6338c62187cff37a1efe11f1d41a34879731bc9db49df75aecf5d582ad09b5c6ded2d86bd1f07c11bd755d1fccc81fe

So I don't think you're calculating Round 2 right. If you want to emulate what the library is doing, set the initial input to TEXT, output to hex and then set round 2 input as hex.

from jssha.

boinggg avatar boinggg commented on May 30, 2024

Oh so the iterations stay in binary. My concern is the ability to test the
iterations manually without a binary input or output. I guess that's a
personal concern though. I just want to be sure I can duplicate the hashing
if this library disappears.
On Mar 18, 2014 11:25 AM, "Brian Turek" [email protected] wrote:

Noble got the explanation 99.9% correct. The issue is I don't believe
you're dealing with your first round output correctly.

Round 1
Input -> ASCII string of test (74657374 in hex)
Output -> A hex encoded string of
ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff

Your Round 2
Input -> ASCII string of
ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
(6565323662306464346166376537343961613161386565336331306165393932336636313839383037373265343733663838313961356434393430653064623237616331383566386130653164356638346638386263383837666436376231343337333263333034636335666139616438653666353766353030323861386666
in hex)
Output ->
5797448d5c775085bc82b808b9d01bb4ef795dfd05ea377d9b537d5e3495179f0b0c03f372518209db3dfbdae47c8529412ce9154dd1c5b99932cdf3b079c125

My Round 2
Input -> hex string of
ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff

Output ->
faadcaf60afd35dfcdb5e9ea0d0a0531f6338c62187cff37a1efe11f1d41a34879731bc9db49df75aecf5d582ad09b5c6ded2d86bd1f07c11bd755d1fccc81fe


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-37969801
.

from jssha.

Caligatio avatar Caligatio commented on May 30, 2024

Closing this as it seems to be solved.

from jssha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.