This commit is contained in:
deepzz0
2016-10-21 00:49:36 +08:00
parent 773378682b
commit 3ace117d0a
7 changed files with 142 additions and 58 deletions

View File

@@ -1,9 +1,12 @@
package main
import (
"crypto/sha1"
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"path"
"regexp"
)
@@ -26,6 +29,28 @@ func VerifyPasswd(origin, name, input string) bool {
return origin == EncryptPasswd(name, input)
}
func SHA1(data []byte) [sha1.Size]byte {
return sha1.Sum(data)
}
func ReadDir(dir string, filter func(name string) bool) (files []string) {
fis, err := ioutil.ReadDir(dir)
if err != nil {
return
}
for _, fi := range fis {
if filter(fi.Name()) {
continue
}
if fi.IsDir() {
files = append(files, ReadDir(path.Join(dir, fi.Name()), filter)...)
continue
}
files = append(files, path.Join(dir, fi.Name()))
}
return
}
func IgnoreHtmlTag(src string) string {
//去除所有尖括号内的HTML代码
re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")