Skip to content

Commit c0ec3a7

Browse files
committed
refactor: Optimize file decryption process and handle empty password case
1 parent e1cb049 commit c0ec3a7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

encryption/encryption.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ func Decrypt(data *[]byte, password string) ([]byte, error) {
5050
}
5151

5252
metadata := (*data)[0]
53-
*data = (*data)[MetadataLength:]
54-
5553
if metadata == 0 {
5654
// No password was used
5755
return *data, nil
5856
}
5957

58+
*data = (*data)[MetadataLength:]
59+
6060
if password == "" {
6161
return nil, errors.New("password is required")
6262
}

test/zip/compressed.bin

-38.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)