Comments (3)
Hello,
Please see the README:
Functions accept and return Uint8Arrays. To convert strings, use external library (for example, nacl.util).
https://github.com/dchest/fast-sha256-js#usage
from fast-sha256-js.
Fair enough, I didn't see the existing report about that before opening mine, and I apologize for my mistake. Once I changed the code to:
function doTestVectors() {
// Test vectors from https://stackoverflow.com/questions/5130513/pbkdf2-hmac-sha2-test-vectors
result1 = toHexString(sha256.pbkdf2(nacl.util.decodeUTF8("password"), nacl.util.decodeUTF8("salt"), 1, 32));
expected1 = "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b";
if (result1 != expected1)
{
alert("Test failed. result1=" + result1 + " expected1=" + expected1);
}
}
After that change it does indeed return the expected result.
However, since this seems a very easy mistake to make, I would encourage you to simply fail if the inputs are not of the correct type, rather than returning what appears to be correct results that are in fact a lie. It's never nice to surprise the user with unexpected or undocumented behavior, especially when they naively appear to be doing everything correctly.
from fast-sha256-js.
Good suggestion, I'll see if it makes performance much worse, and if it doesn't I'll add a type check. Thanks!
from fast-sha256-js.
Related Issues (7)
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 fast-sha256-js.