feat: add 3-layer-encryption for attachments

This commit is contained in:
thecodrr
2021-10-25 11:35:00 +05:00
parent 69defdb367
commit 51794e001e
4 changed files with 94 additions and 20 deletions

View File

@@ -1,3 +1,5 @@
import { randomBytes } from "../utils/random";
export default class Storage {
constructor(context) {
this.storage = context;
@@ -46,4 +48,10 @@ export default class Storage {
getCryptoKey(name) {
return this.storage.getCryptoKey(name);
}
async generateRandomKey() {
const passwordBytes = randomBytes(124);
const password = passwordBytes.toString("base64");
return await this.storage.generateCryptoKey(password, false);
}
}