W3 specification
const key = await crypto.subtle.importKey(
"raw", // only raw format
password, // BufferSource
"PBKDF2",
false, // only false
["deriveBits", "deriveKey"],
);
const salt = crypto.getRandomValues(new Uint8Array(4));
const derivedBits = await crypto.subtle.deriveBits(
{
name: "PBKDF2",
salt,
iterations: 1000,
hash: "SHA-256",
},
key,
128,
);
const salt = crypto.getRandomValues(new Uint8Array(4));
const derivedKey = await crypto.subtle.deriveKey(
{
name: "PBKDF2",
salt,
iterations: 1000,
hash: "SHA-256",
},
key,
{
name: "AES-CBC",
length: 128,
},
false,
["encrypt", "decrypt"],
);