admin-vben/internal/node-utils/src/hash.ts

19 lines
394 B
TypeScript
Raw Normal View History

2024-05-19 13:20:42 +00:00
import { createHash } from 'node:crypto';
/**
* hash
* @param content
* @param hashLSize
*/
function generatorContentHash(content: string, hashLSize?: number) {
const hash = createHash('md5').update(content, 'utf8').digest('hex');
if (hashLSize) {
return hash.slice(0, hashLSize);
}
return hash;
}
export { generatorContentHash };