瀏覽代碼

remove extra padding on decrypt

Steven Schobert 9 年之前
父節點
當前提交
ef10b279ea
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      rncryptor.go

+ 4 - 1
rncryptor.go

@@ -50,5 +50,8 @@ func Decrypt(password, text []byte) ([]byte, error) {
   decrypter := cipher.NewCBCDecrypter(cipherBlock, iv)
   decrypter.CryptBlocks(decrypted, decrypted)
 
-  return decrypted, nil
+  length := len(decrypted)
+  unpadding := int(decrypted[length-1])
+
+  return decrypted[:(length - unpadding)], nil
 }