refactor: eiblog

This commit is contained in:
deepzz0
2021-04-26 15:51:16 +08:00
parent bd69c62254
commit 68e01cdf1f
843 changed files with 3606 additions and 1007377 deletions

1
tools/README.md Normal file
View File

@@ -0,0 +1 @@
Supporting tools for this project. Note that these tools can import code from the /pkg and /internal directories.

39
tools/tools.go Normal file
View File

@@ -0,0 +1,39 @@
// Package tools provides ...
package tools
import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"path"
)
// EncryptPasswd encrypt password
func EncryptPasswd(name, pass string) string {
salt := "%$@w*)("
h := sha256.New()
io.WriteString(h, name)
io.WriteString(h, salt)
io.WriteString(h, pass)
return fmt.Sprintf("%x", h.Sum(nil))
}
// ReadDirFiles 读取目录
func ReadDirFiles(dir string, filter func(name string) bool) (files []string) {
fileInfos, err := ioutil.ReadDir(dir)
if err != nil {
return
}
for _, fi := range fileInfos {
if filter(fi.Name()) {
continue
}
if fi.IsDir() {
files = append(files, ReadDirFiles(path.Join(dir, fi.Name()), filter)...)
continue
}
files = append(files, path.Join(dir, fi.Name()))
}
return
}