97 lines
2.1 KiB
TypeScript
97 lines
2.1 KiB
TypeScript
/**
|
|
* {}
|
|
* @author yutent<yutent.io@gmail.com>
|
|
* @date 2024/12/12 15:41:25
|
|
*/
|
|
|
|
declare module 'crypto.js' {
|
|
import crypto from 'node:crypto'
|
|
|
|
// 原生 crypto 模块
|
|
export { crypto }
|
|
|
|
/**
|
|
* @deprecated Use `crypto` instead.
|
|
*/
|
|
export const origin: typeof crypto
|
|
|
|
// 随机数生成
|
|
export function rand(len: number, forceNum?: boolean): string
|
|
|
|
// 生成唯一 uuid
|
|
export function uuid(pipe?: string): string
|
|
|
|
export function base64encode(str: string, urlFriendly?: boolean): string
|
|
|
|
export function base64decode(str: string, urlFriendly?: boolean): string
|
|
|
|
export function md5(data: string, encode?: string): string | Buffer
|
|
|
|
export function md5Sign(path: string, encode?: string): string | Buffer
|
|
|
|
export function sha1(data: string, encode?: string): string | Buffer
|
|
|
|
export function sha1Sign(path: string, encode?: string): string | Buffer
|
|
|
|
export function sha256(data: string, encode?: string): string | Buffer
|
|
|
|
export function sha256Sign(path: string, encode?: string): string | Buffer
|
|
|
|
export function sha512(data: string, encode?: string): string | Buffer
|
|
|
|
export function sha512Sign(path: string, encode?: string): string | Buffer
|
|
|
|
//
|
|
export function hash(
|
|
mode: string,
|
|
data: string | Buffer,
|
|
outEncode?: string
|
|
): string | Buffer
|
|
|
|
//
|
|
export function hmac(
|
|
mode: string,
|
|
data: string | Buffer,
|
|
key: string | Buffer,
|
|
outEncode?: string
|
|
): string | Buffer
|
|
|
|
//
|
|
export function cipher(
|
|
mode: string,
|
|
data: string | Buffer,
|
|
key: string | Buffer,
|
|
inEncode?: string,
|
|
outEncode?: string
|
|
): string | Buffer
|
|
|
|
//
|
|
export function decipher(
|
|
mode: string,
|
|
data: string | Buffer,
|
|
key: string | Buffer,
|
|
inEncode?: string,
|
|
outEncode?: string
|
|
): string | Buffer
|
|
|
|
//
|
|
export function cipheriv(
|
|
mode: string,
|
|
data: string | Buffer,
|
|
key: string | Buffer,
|
|
iv: string | Buffer,
|
|
inEncode?: string,
|
|
outEncode?: string
|
|
): string | Buffer
|
|
|
|
//
|
|
export function decipheriv(
|
|
mode: string,
|
|
data: string | Buffer,
|
|
key: string | Buffer,
|
|
iv: string | Buffer,
|
|
inEncode?: string,
|
|
outEncode?: string
|
|
): string | Buffer
|
|
}
|