15 lines
283 B
JavaScript
15 lines
283 B
JavaScript
|
function reconstructHash(hash){
|
||
|
return hash.padStart(64, 0)
|
||
|
}
|
||
|
|
||
|
|
||
|
function verifyBlock(raw, hash){
|
||
|
var encoder = new TextEncoder("utf-8")
|
||
|
hash = reconstructHash(hash)
|
||
|
if (doHashHex(encoder.encode(raw)) != hash){
|
||
|
throw new Error("Hash does not match")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|