파일 다운로드 임시 구현

This commit is contained in:
static
2025-01-05 20:45:31 +09:00
parent 9ca6444bc9
commit c580556740
7 changed files with 137 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
import { encodeToBase64, decodeFromBase64 } from "./util";
import { encodeString, decodeString, encodeToBase64, decodeFromBase64 } from "./util";
export const generateMasterKey = async () => {
return {
@@ -81,3 +81,12 @@ export const decryptData = async (ciphertext: BufferSource, iv: string, dataKey:
ciphertext,
);
};
export const encryptString = async (plaintext: string, dataKey: CryptoKey) => {
const { ciphertext, iv } = await encryptData(encodeString(plaintext), dataKey);
return { ciphertext: encodeToBase64(ciphertext), iv };
};
export const decryptString = async (ciphertext: string, iv: string, dataKey: CryptoKey) => {
return decodeString(await decryptData(decodeFromBase64(ciphertext), iv, dataKey));
};