1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00
ladybird/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-encrypt.html
2025-03-20 11:50:49 +01:00

33 lines
903 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
asyncTest(async done => {
const encoder = new TextEncoder();
const message = "Hello friends";
const encodedMessage = encoder.encode(message);
const generated = await window.crypto.subtle.generateKey(
{
name: "RSA-OAEP",
modulusLength: 512,
publicExponent: new Uint8Array([1, 0, 1]),
hash: "SHA-1",
},
true,
["encrypt", "decrypt"]
);
const ciphertext = await window.crypto.subtle.encrypt(
{
name: "RSA-OAEP",
},
generated.publicKey,
encodedMessage
);
const buffer = new Uint8Array(ciphertext);
println(`Encrypted OK with ${buffer.byteLength} bytes`);
done();
});
</script>