值
一個 Array,其中包含以下列表中的字串:
示例
js
const rawKey = window.crypto.getRandomValues(new Uint8Array(16));
// Import an AES secret key from an ArrayBuffer containing the raw bytes.
// Takes an ArrayBuffer string containing the bytes, and returns a Promise
// that will resolve to a CryptoKey representing the secret key.
function importSecretKey(rawKey) {
return window.crypto.subtle.importKey("raw", rawKey, "AES-GCM", true, [
"encrypt",
"decrypt",
]);
}
const key = importSecretKey(rawKey);
console.log(
`The following usages are reported for this key: ${key.usages.toString()}`,
);
規範
| 規範 |
|---|
| Web 加密級別 2 # dom-cryptokey-usages |
瀏覽器相容性
載入中…