feat(utils): 添加 BCrypt 加密工具类
- 新增 BCrypt.kt 文件,提供 BCrypt 加密相关方法 - 更新 build.gradle.kts,调整依赖项和版本 - 更新 gradle.properties,升级版本号至 4.1.1 - 更新 HashUtils.kt,使用新的 BCrypt 工具类 - 添加 NOTICE 文件,记录第三方软件的版权声明
This commit is contained in:
@@ -16,25 +16,20 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile HashUtils.kt
|
||||
* LastUpdate 2025-09-15 09:38:04
|
||||
* LastUpdate 2025-09-17 11:57:26
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
@file:JvmName("HashUtils")
|
||||
|
||||
package com.mingliqiye.utils.hash
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
import org.mindrot.jbcrypt.BCrypt
|
||||
|
||||
import com.mingliqiye.utils.bcrypt.BCrypt
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.security.MessageDigest
|
||||
import java.security.NoSuchAlgorithmException
|
||||
import java.security.Security
|
||||
|
||||
private val _addProvider = run {
|
||||
Security.addProvider(BouncyCastleProvider())
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定文件的哈希值。
|
||||
@@ -92,7 +87,7 @@ private fun bytesToHex(bytes: ByteArray): String {
|
||||
* @return 加密后的 BCrypt 哈希字符串
|
||||
*/
|
||||
fun bcrypt(string: String): String {
|
||||
return BCrypt.hashpw(string, BCrypt.gensalt())
|
||||
return BCrypt.hashpw(string)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user