mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
파일 다운로드 임시 구현
This commit is contained in:
@@ -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));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user