mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
pcrypto: update
This commit is contained in:
parent
78c770d37d
commit
a729a4fafe
@ -49,7 +49,6 @@ func (pc *Pcrypto) Encrypt(src []byte) ([]byte, error) {
|
|||||||
defer zwr.Close()
|
defer zwr.Close()
|
||||||
zwr.Write(src)
|
zwr.Write(src)
|
||||||
zwr.Flush()
|
zwr.Flush()
|
||||||
fmt.Println("com,src,en", len(src), len(zbuf.Bytes()))
|
|
||||||
|
|
||||||
// aes
|
// aes
|
||||||
src = pKCS7Padding(zbuf.Bytes(), aes.BlockSize)
|
src = pKCS7Padding(zbuf.Bytes(), aes.BlockSize)
|
||||||
@ -57,8 +56,6 @@ func (pc *Pcrypto) Encrypt(src []byte) ([]byte, error) {
|
|||||||
crypted := make([]byte, len(src))
|
crypted := make([]byte, len(src))
|
||||||
blockMode.CryptBlocks(crypted, src)
|
blockMode.CryptBlocks(crypted, src)
|
||||||
|
|
||||||
fmt.Println("aes,src,en", len(src), len(crypted))
|
|
||||||
|
|
||||||
// base64
|
// base64
|
||||||
return []byte(base64.StdEncoding.EncodeToString(crypted)), nil
|
return []byte(base64.StdEncoding.EncodeToString(crypted)), nil
|
||||||
}
|
}
|
||||||
@ -87,7 +84,10 @@ func (pc *Pcrypto) Decrypt(str []byte) ([]byte, error) {
|
|||||||
|
|
||||||
// gunzip
|
// gunzip
|
||||||
zbuf := bytes.NewBuffer(decryptText)
|
zbuf := bytes.NewBuffer(decryptText)
|
||||||
zrd, _ := gzip.NewReader(zbuf)
|
zrd, err := gzip.NewReader(zbuf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
defer zrd.Close()
|
defer zrd.Close()
|
||||||
data, _ = ioutil.ReadAll(zrd)
|
data, _ = ioutil.ReadAll(zrd)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user