mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
사소한 리팩토링 2
This commit is contained in:
@@ -5,16 +5,6 @@ export const digestMessage = async (message: BufferSource) => {
|
||||
return await crypto.subtle.digest("SHA-256", message);
|
||||
};
|
||||
|
||||
export const createStreamingHmac = async (hmacSecret: CryptoKey) => {
|
||||
const keyBytes = new Uint8Array(await crypto.subtle.exportKey("raw", hmacSecret));
|
||||
const h = hmac.create(sha256, keyBytes);
|
||||
|
||||
return {
|
||||
update: (data: Uint8Array) => h.update(data),
|
||||
digest: () => h.digest(),
|
||||
};
|
||||
};
|
||||
|
||||
export const generateHmacSecret = async () => {
|
||||
return {
|
||||
hmacSecret: await crypto.subtle.generateKey(
|
||||
@@ -28,6 +18,10 @@ export const generateHmacSecret = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const signMessageHmac = async (message: BufferSource, hmacSecret: CryptoKey) => {
|
||||
return await crypto.subtle.sign("HMAC", hmacSecret, message);
|
||||
export const createHmacStream = async (hmacSecret: CryptoKey) => {
|
||||
const h = hmac.create(sha256, new Uint8Array(await crypto.subtle.exportKey("raw", hmacSecret)));
|
||||
return {
|
||||
update: (data: Uint8Array) => h.update(data),
|
||||
digest: () => h.digest(),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user