1、实现富文本编辑器

2、实现文档转换为PDF、MOBI、EPUB、Word格式
3、实现登录后跳转到来源地址
This commit is contained in:
Minho
2018-01-26 17:17:38 +08:00
parent e1ec6bb788
commit 882d93e7b0
57 changed files with 1572 additions and 1475 deletions

View File

@@ -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)
}
}