feat: totp close #9

This commit is contained in:
naiba
2021-01-04 21:46:18 +08:00
committed by dushixiang
parent 2d160c70f9
commit 3bf8fe6684
11 changed files with 213 additions and 49 deletions

View File

@ -1,14 +1,19 @@
package utils
import (
"bytes"
"database/sql/driver"
"encoding/base64"
"fmt"
"github.com/gofrs/uuid"
"golang.org/x/crypto/bcrypt"
"image"
"image/png"
"net"
"os"
"strconv"
"time"
"github.com/gofrs/uuid"
"golang.org/x/crypto/bcrypt"
)
type JsonTime struct {
@ -81,6 +86,14 @@ func Tcping(ip string, port int) bool {
return true
}
func ImageToBase64Encode(img image.Image) (string, error) {
var buf bytes.Buffer
if err := png.Encode(&buf, img); err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(buf.Bytes()), nil
}
// 判断所给路径文件/文件夹是否存在
func FileExists(path string) bool {
_, err := os.Stat(path) //os.Stat获取文件信息