Skip to content

Commit

Permalink
🔥 清理无用代码
Browse files Browse the repository at this point in the history
  • Loading branch information
cfdxkk committed Mar 21, 2024
1 parent d70d6ee commit 252fa40
Showing 1 changed file with 1 addition and 45 deletions.
46 changes: 1 addition & 45 deletions src/common/HashTool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import bcrypt from 'bcrypt'

const HASH_ROUND = 8 // Bcrypt Hash 轮次,数值越大越慢,越安全。

const HASH_ROUND = 8 // Bcrypt Hash 轮次,数值越大越慢,越安全。 // WARN 千万不要改!
/**
* 使用 Bcrypt Hash 一个密码
* @param password 原密码
Expand All @@ -20,46 +19,3 @@ export function hashPasswordSync(password: string): string {
export function comparePasswordSync(passwordOrigin: string, passwordHash: string): boolean {
return bcrypt.compareSync(passwordOrigin, passwordHash)
}


// /**
// * 将输入的字符串进行简单的 SHA-256 哈希
// *
// * @param data 输入的字符串
// * @returns hash
// */
// export const hashData = async (data: string): Promise<string> => {
// if (data) {
// const encoder = new TextEncoder()
// const dataUint8Array = encoder.encode(data)
// const hashBuffer = await crypto.subtle.digest('SHA-256', dataUint8Array)
// .catch(e => {
// console.error('something error in function hashData -> crypto.subtle.digest', e)
// }) as Buffer
// const hashArray = Array.from(new Uint8Array(hashBuffer))

// return hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
// } else {
// console.error('something error in function hashData, required data is empty')
// return ''
// }
// }



// const scrypt = util.promisify(crypto.scrypt)
// /**
// * 生成加盐 hash
// *
// * @param data 被 hash 的字符串
// * @param salt 盐
// * @returns 加盐hash
// */
// export const generateSaltedHash = async (data: string, salt: string): Promise<string> => {
// const hash = await scrypt(data, salt, 64)
// .catch(e => {
// console.error('something error in function generateSaltedHash -> scrypt', e)
// }) as Buffer
// return hash.toString('hex')
// }

0 comments on commit 252fa40

Please sign in to comment.