ladybird/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-encrypt.html

34 lines
903 B
HTML
Raw Normal View History

2025-03-18 19:28:35 +01:00
<!DOCTYPE html>
2024-04-09 02:08:56 +02:00
<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>