pcrypto: update

This commit is contained in:
fatedier 2016-04-05 16:17:31 +08:00
parent 78c770d37d
commit a729a4fafe
1 changed files with 4 additions and 4 deletions

View File

@ -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)