mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
refactor: eiblog
This commit is contained in:
1
tools/README.md
Normal file
1
tools/README.md
Normal 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
39
tools/tools.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user