Files
core_ng/@sammo/crypto/src/SHA2.ts
T
Hide_D e59f9a9659 monorepo 버전 준비
## @strpc
기존 RPC를 package화

### @strpc/express
express의 middleware + router 결함

## @sammo
게임 전체
- server, client
- gateway_server, gateway_client
2023-09-23 16:29:18 +00:00

20 lines
635 B
TypeScript

import { isBufferSource } from "./types.js";
import { BSON } from "bson";
import { type Bsonifiable, bsonify } from "@sammo/util";
import { isArray, isDate, isObject } from "lodash-es";
const subtle = globalThis.crypto.subtle;
export async function sha256(msg: Bsonifiable | BufferSource): Promise<ArrayBuffer> {
if (!isBufferSource(msg)) {
msg = BSON.serialize(bsonify(msg));
}
return await subtle.digest('SHA-256', msg);
}
export async function sha512(msg: Bsonifiable | BufferSource): Promise<ArrayBuffer> {
if (!isBufferSource(msg)) {
msg = BSON.serialize(bsonify(msg));
}
return await subtle.digest('SHA-512', msg);
}