What does the SHA256 Function do with "non valid input"
NeikiDev opened this issue · comments
Neiki commented
Hey so my friend send me an script where he tried to hash a file.
He did it wrong (we fixed it already) but i was wondering why, if i give the SHA256 hash function an Buffer object, it always gives me back the same hash "4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e"
example script:
const CryptoJS = require("crypto-js");
console.log("HASH: " + CryptoJS.SHA256(function() {}));
console.log("HASH: " + CryptoJS.SHA256(Buffer));
console.log("HASH: " + CryptoJS.SHA256(ArrayBuffer));
console.log("HASH: " + CryptoJS.SHA256(String));
console.log("HASH: " + CryptoJS.SHA256(Number));
console.log("HASH: " + CryptoJS.SHA256(Boolean));
output
HASH: 4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e
HASH: 4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e
HASH: 4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e
HASH: 4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e
HASH: 4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e
HASH: 4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e
its always the same hash, so what does the function hash in that moment? whats the value of the hash?