CryptoKey

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Giao diện CryptoKey của Web Crypto API biểu diễn một khóa mật mã thu được từ một trong các phương thức SubtleCrypto: generateKey(), deriveKey(), importKey() hoặc unwrapKey().

Vì lý do bảo mật, giao diện CryptoKey chỉ có thể được sử dụng trong secure context.

Thuộc tính thể hiện

CryptoKey.type Read only

Loại khóa mà đối tượng biểu diễn. Thuộc tính này có thể nhận một trong các giá trị sau: "secret", "private" hoặc "public".

CryptoKey.extractable Read only

Giá trị boolean cho biết khóa có thể được trích xuất bằng SubtleCrypto.exportKey() hoặc SubtleCrypto.wrapKey() hay không.

CryptoKey.algorithm Read only

Một đối tượng mô tả thuật toán mà khóa này có thể dùng cùng với mọi tham số bổ sung liên quan.

CryptoKey.usages Read only

Một Array các chuỗi, cho biết có thể làm gì với khóa. Các giá trị có thể có của phần tử mảng là "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey""unwrapKey".

Ví dụ

Các ví dụ cho phương thức SubtleCrypto thường sử dụng đối tượng CryptoKey. Ví dụ:

Thông số kỹ thuật

Specification
Web Cryptography Level 2
# cryptokey-interface

Khả năng tương thích trình duyệt

Xem thêm