值
一个 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 |
浏览器兼容性
加载中…