feat: 加密AES包和ssh连接包

This commit is contained in:
TsMask
2024-02-20 20:21:50 +08:00
parent 6cf7d7b4b6
commit c0bcc91efe
3 changed files with 317 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package crypto
import (
"golang.org/x/crypto/bcrypt"
)
// BcryptHash Bcrypt密码加密
func BcryptHash(originStr string) string {
hash, err := bcrypt.GenerateFromPassword([]byte(originStr), bcrypt.DefaultCost)
if err != nil {
return ""
}
return string(hash)
}
// BcryptCompare Bcrypt密码匹配检查
func BcryptCompare(originStr, hashStr string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hashStr), []byte(originStr))
return err == nil
}