mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb: Implement RSAOAEP.encrypt()
This commit is contained in:
Notes:
github-actions[bot]
2024-10-27 10:32:23 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/48bd0947121 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1976
32
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-encrypt.html
Normal file
32
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-encrypt.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user