Buckets:
| import { DecrypterAesMode } from './decrypter-aes-mode'; | |
| export default class AESCrypto { | |
| private subtle: SubtleCrypto; | |
| private aesIV: Uint8Array; | |
| private aesMode: DecrypterAesMode; | |
| constructor(subtle: SubtleCrypto, iv: Uint8Array, aesMode: DecrypterAesMode) { | |
| this.subtle = subtle; | |
| this.aesIV = iv; | |
| this.aesMode = aesMode; | |
| } | |
| decrypt(data: ArrayBuffer, key: CryptoKey) { | |
| switch (this.aesMode) { | |
| case DecrypterAesMode.cbc: | |
| return this.subtle.decrypt( | |
| { name: 'AES-CBC', iv: this.aesIV }, | |
| key, | |
| data, | |
| ); | |
| case DecrypterAesMode.ctr: | |
| return this.subtle.decrypt( | |
| { name: 'AES-CTR', counter: this.aesIV, length: 64 }, //64 : NIST SP800-38A standard suggests that the counter should occupy half of the counter block | |
| key, | |
| data, | |
| ); | |
| default: | |
| throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`); | |
| } | |
| } | |
| } | |
Xet Storage Details
- Size:
- 956 Bytes
- Xet hash:
- 05a0d665869e7c839eb3c86de640e7ab46de18fe8fe6c93371503161ecbb228d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.