mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
Tests/LibWeb: Add test for SubtleCrypto digest
This commit is contained in:
parent
d89e617a42
commit
bad7f0091f
2 changed files with 26 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
|||
SHA-1 502e36a76e3575bc45f657de545aba75c2f1bc0c
|
||||
SHA-256 b034c01d603911280626f67ac0d36b67b8ccff0e37a3f25a59fe55dd002dac52
|
||||
SHA-384 f1916d6222160c71708e1040c6c1ef0cff7b63f9fc17cbf87fb89193a30b160a72b02fabe012f4d3acc455a6f7d69f3e
|
||||
SHA-512 d073f8e74151dd501c94728735013a083a497d743adf6bdfbcbfe8a99b7c7c7d35e9d582515f2bb5c8e3c74b30567353910d35cf5b095112602f12e62b391cf5
|
22
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-digest.html
Normal file
22
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-digest.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
function bufferToHex(buffer) {
|
||||
return [...new Uint8Array(buffer)].map(b => b.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
async function printDigest(algorithm, encoded_message) {
|
||||
const digest = await window.crypto.subtle.digest(algorithm, encoded_message);
|
||||
println(`${algorithm} ${bufferToHex(digest)}`);
|
||||
}
|
||||
asyncTest(async done => {
|
||||
const encoder = new TextEncoder();
|
||||
const message = "Hello friends";
|
||||
const encoded_message = encoder.encode(message);
|
||||
|
||||
await printDigest("SHA-1", encoded_message);
|
||||
await printDigest("SHA-256", encoded_message);
|
||||
await printDigest("SHA-384", encoded_message);
|
||||
await printDigest("SHA-512", encoded_message);
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue