Skip to content

Commit 3bbeafc

Browse files
committed
Update examples
1 parent e299562 commit 3bbeafc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

example/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
### Encrypting the file
44
```
5-
go run example/main.go -action=encrypt -in=bitcoin.pdf -out=bitcoin-enc.pdf -hash=00000000000000000000000000000000000000 -preimage=0000000000000000000000000000000000000000
5+
go run example/main.go -action=encrypt -in=bitcoin.pdf -out=bitcoin-enc.pdf -hash=84645f0ccdd6f4695d655b3b6e8dfe6f4f35ad55fac62981c98216d74f87bae5 -preimage=28a794564e8c20a64b6376c4ebdd84ae3525f45342b957f9334f6fdb86c7615d
66
```
77

88
#### Decrypting the file
99
```
10-
go run example/main.go -action=decrypt -in=bitcoin-enc.pdf -out=bitcoin-dec.pdf -hash=00000000000000000000000000000000000000 -preimage=0000000000000000000000000000000000000000
10+
go run example/main.go -action=decrypt -in=bitcoin-enc.pdf -out=bitcoin-dec.pdf -hash=84645f0ccdd6f4695d655b3b6e8dfe6f4f35ad55fac62981c98216d74f87bae5 -preimage=28a794564e8c20a64b6376c4ebdd84ae3525f45342b957f9334f6fdb86c7615d
1111
```

example/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ func decrypt(inPath, outPath, preimage string, chunkSize int64) error {
100100
return err
101101
}
102102

103-
decryptedFile, index, err := bitstream.Decrypt(preimageBytes, f, chunkSize)
103+
paymentHashBytes, err := hex.DecodeString(paymentHash)
104+
if err != nil {
105+
return err
106+
}
107+
108+
decryptedFile, index, err := bitstream.Decrypt(paymentHashBytes, preimageBytes, f, chunkSize)
104109
if err != nil {
105110
if index != -1 {
106111
proof, err := bitstream.GenerateProof(f, chunkSize, 2*index)

0 commit comments

Comments
 (0)