I want to use package hash from npm like md5,sha1,sha256 and sha512 with class . I successed hash using md5,sh1,sha256 but not sha512. I've got error like this "The value of "offset" is out of range. It must be >= 0 and <= 1. Received 4"
This my code:
var md5 = require("md5");
var sha1 = require("sha1");
var sha256 = require("sha256");
var sha512 = require("sha512");
class Hess {
md5(params) {
console.log(md5(params));
}
sha1(params) {
console.log(sha1(params));
}
sha256(params) {
console.log(sha256(params));
}
sha512(params) {
var hash = sha512(params)
console.log(hash.toString("hex"));
}
}
const Hash = new Hess();
Hash.md5("secret");
Hash.sha1("secret");
Hash.sha256("secret");
Hash.sha512("hello");
How i repair my code so that not error and the result of sha512 successed?