mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
1、实现富文本编辑器
2、实现文档转换为PDF、MOBI、EPUB、Word格式 3、实现登录后跳转到来源地址
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package utils
|
||||
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
mt "math/rand"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"crypto/sha512"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
mt "math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -20,6 +19,7 @@ const (
|
||||
stretching_password = 500
|
||||
salt_local_secret = "ahfw*&TGdsfnbi*^Wt"
|
||||
)
|
||||
|
||||
//加密密码
|
||||
func PasswordHash(pass string) (string, error) {
|
||||
|
||||
@@ -45,8 +45,9 @@ func PasswordHash(pass string) (string, error) {
|
||||
return password, nil
|
||||
|
||||
}
|
||||
|
||||
//校验密码是否有效
|
||||
func PasswordVerify(hashing string, pass string) (bool, error) {
|
||||
func PasswordVerify(hashing string, pass string) (bool, error) {
|
||||
data := trim_salt_hash(hashing)
|
||||
|
||||
interation, _ := strconv.ParseInt(data["interation_string"], 10, 64)
|
||||
@@ -56,7 +57,7 @@ func PasswordVerify(hashing string, pass string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if (data["salt_secret"]+delmiter+data["interation_string"]+delmiter+has+delmiter+data["salt"]) == hashing {
|
||||
if (data["salt_secret"] + delmiter + data["interation_string"] + delmiter + has + delmiter + data["salt"]) == hashing {
|
||||
return true, nil
|
||||
} else {
|
||||
return false, nil
|
||||
@@ -110,7 +111,7 @@ func trim_salt_hash(hash string) map[string]string {
|
||||
}
|
||||
func salt(secret string) (string, error) {
|
||||
|
||||
buf := make([]byte, saltSize, saltSize + md5.Size)
|
||||
buf := make([]byte, saltSize, saltSize+md5.Size)
|
||||
_, err := io.ReadFull(rand.Reader, buf)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -134,4 +135,4 @@ func salt_secret() (string, error) {
|
||||
|
||||
func randInt(min int, max int) int {
|
||||
return min + mt.Intn(max-min)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user