18 lines
436 B
JavaScript
18 lines
436 B
JavaScript
// src/utils/encryption.js
|
|
import sm3 from 'sm-crypto/src/sm3'
|
|
import { SM_CONFIG } from './configure'
|
|
|
|
// SM3 哈希
|
|
export function hashSM3(text) {
|
|
// 对数据进行哈希计算
|
|
return sm3(text)
|
|
}
|
|
|
|
// 使用 SM3 进行哈希并加入盐值
|
|
export function hashWithSM3AndSalt(text) {
|
|
// 将文本和盐值拼接在一起
|
|
const textWithSalt = SM_CONFIG.SALT + text
|
|
// 使用 SM3 进行哈希
|
|
return hashSM3(textWithSalt)
|
|
}
|