mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 16:16:55 +00:00
프론트엔드 암호 모듈 리팩토링
This commit is contained in:
19
src/lib/modules/crypto/util.ts
Normal file
19
src/lib/modules/crypto/util.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export const encodeToBase64 = (data: ArrayBuffer) => {
|
||||
return btoa(String.fromCharCode(...new Uint8Array(data)));
|
||||
};
|
||||
|
||||
export const decodeFromBase64 = (data: string) => {
|
||||
return Uint8Array.from(atob(data), (c) => c.charCodeAt(0)).buffer;
|
||||
};
|
||||
|
||||
export const concatenateBuffers = (...buffers: ArrayBuffer[]) => {
|
||||
const arrays = buffers.map((buffer) => new Uint8Array(buffer));
|
||||
const totalLength = arrays.reduce((acc, array) => acc + array.length, 0);
|
||||
const result = new Uint8Array(totalLength);
|
||||
|
||||
arrays.reduce((offset, array) => {
|
||||
result.set(array, offset);
|
||||
return offset + array.length;
|
||||
}, 0);
|
||||
return result;
|
||||
};
|
||||
Reference in New Issue
Block a user