Giter Club home page Giter Club logo

fast-sha256-js's Issues

Suggestion: input type check

I wonder if an input type check, say in Hash.prototype.update(data), would be appropriate for idiots like me who just assume that a string is fine :)

    Hash.prototype.update = function (data, dataLength) {
        if (typeof data === "string") {
          throw new Error("Input data should be Uint8Array");
        }

I got much better results when I converted my strings to Uint8Array after noticing that my result was different than that produced by sha256sum at the command line.

pbkdf2 gives always the same result

pbkdf2 always gives me the same result regardless of the password:

sha256.pbkdf2('b', 'salt', 10, 32).join(',')
"234,39,191,6,86,158,63,177,246,157,96,178,195,13,125,54,91,1,37,107,241,3,140,34,21,102,65,171,57,106,121,67"

sha256.pbkdf2('a', 'salt', 10, 32).join(',')
"234,39,191,6,86,158,63,177,246,157,96,178,195,13,125,54,91,1,37,107,241,3,140,34,21,102,65,171,57,106,121,67"

What am I doing wrong?

[RESEARCH] Почему хэш отличается от ASMCrypto?

Дмитрий,

  • положим рядом index.html, asmcrypto.js и sha256.min.js (все три в архиве)
  • посчитаем PBKDF2_HMAC_SHA256 с параметрами password, salt, 1000, 20
  • сконвертируем вывод Uint8Array в Hex (можно и в Base64, суть вопроса не изменится)

Asmcrypto: 632c2812e46d4604102ba7618e9d6d7d2f8128f6
DmitryChe: d1035cbdf15c9f80ef8c9fc01ae5ec06552943de

Хэши отличаются. Почему?

PKBDF2 Doesn't appear to generate exepcted values

I am trying to get corresponding values between JavaScript code and Java code. When that didn't happen, I went looking for test vectors, and added this function to my JavaScript, which fails to produce the expected output for the first test vector.

function doTestVectors() {
// Test vectors from https://stackoverflow.com/questions/5130513/pbkdf2-hmac-sha2-test-vectors
result1 = toHexString(sha256.pbkdf2("password", "salt", 1, 32));
expected1 = "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b";
if (result1 != expected1)
{
alert("Test failed. result1=" + result1);
}
}

It produces:
Test failed. result1=a4a11ce5fbe8f96bf3028035286c2c9274cd4259cbc224e37a73d971923903d3

Perhaps you could add these known good test vectors to the code and then hopefully also get a match?

Same result on Chromium-based browsers

Some problem on Chromium-based browsers. (Maybe in other too.)
For two different passwords returns same result.
For example:

console.log(sha256.pbkdf2('dsddsdsds1', '', 0, 32));
console.log(sha256.pbkdf2('sddsdsdse1', '', 0, 32));

sha256.hmac return garbled hash value

I was trying to use the sha256.hmac function to generate hmac sha256 hash, but I got some garbled code.

//convert String to Uint8Array
var msg = new TextEncoder("utf-8").encode("/v2/radios?page=1&size=10&catalog=all:7690d85d-7777-2930-040c-9241b52682ab");
var key  = new TextEncoder("utf-8").encode("q23IN6hB7p"); 
var hash = sha256.hmac(key, msg);
//convert Uint8Array to String
console.log(new TextDecoder("utf-8").decode(hash));  // result is garbled code: gUm7_���������)���V�Ύ����kb�l�T

version: v1.0.0
browser: Chrome 62

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.