mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
14 lines
371 B
TypeScript
14 lines
371 B
TypeScript
import crypto from 'crypto';
|
|
|
|
const encrypt = (algorithm, content) => {
|
|
const hash = crypto.createHash(algorithm);
|
|
hash.update(content);
|
|
return hash.digest('hex');
|
|
};
|
|
|
|
export const sha1 = (content: string) => encrypt('sha1', content);
|
|
export const md5 = (content: string) => encrypt('md5', content);
|
|
|
|
global.Hydro.lib.md5 = md5;
|
|
global.Hydro.lib.sha1 = sha1;
|