1- # Synology Cloud Sync decryption in Go
1+ # Synology Cloud Sync encryption/ decryption in Go
22
33[ ![ GoDoc] ( https://godoc.org/github.com/maxlaverse/synocrypto?status.svg )] ( https://godoc.org/github.com/maxlaverse/synocrypto )
44[ ![ test] ( https://github.com/maxlaverse/synocrypto/actions/workflows/workflow.yaml/badge.svg )] ( https://github.com/maxlaverse/synocrypto/actions/workflows/workflow.yaml )
@@ -45,7 +45,7 @@ GLOBAL OPTIONS:
4545
4646## Library
4747
48- ### Usage
48+ ### Decryption Usage
4949
5050``` go
5151encFile , err := os.Open (" ./my-encrypted-file.jpg" )
@@ -70,18 +70,36 @@ if err != nil {
7070}
7171```
7272
73- ### Encryption Support
73+ ### Encryption Usage
7474
75- The library has a prototype implementation for encrypting files.
76- Files encrypted with it can often (always?) be decrypted using the library again.
77- However, Cloudsync sometimes fails to decrypt them with errors related to compression:
78- ```
79- Sep 16 22:54:25 [ERROR] lz4-processor.cpp(239): LZ4F_decompress LOGIC ERROR: inbuf_consumed='0' inbuf_size='8'
80- Sep 16 22:54:25 [ERROR] pipeline.cpp(119): Failed when read
81- Sep 16 22:54:25 [ERROR] encrypt-file.cpp(148): Failed when reading from decryptor.
82- Sep 16 22:54:25 [WARNING] worker.cpp(3211): Worker (15): Failed to decrypt file
75+ ``` go
76+ plainFile , err := os.Open (" ./my-plain-file.jpg" )
77+ if err != nil {
78+ panic (err)
79+ }
80+ defer plainFile.Close ()
81+
82+ encFile , err := os.OpenFile (" ./my-encrypted-file.jpg" , os.O_CREATE |os.O_WRONLY , 0644 )
83+ if err != nil {
84+ panic (err)
85+ }
86+ defer encFile.Close ()
87+
88+ privateKey , err := ioutil.ReadFile (" private.pem" )
89+ if err != nil {
90+ panic (err)
91+ }
92+
93+ encrypter := synocrypto.NewEncrypter (synocrypto.EncrypterOptions {
94+ Password : " synocrypto" ,
95+ PrivateKey : privateKey,
96+ })
97+
98+ err = encrypter.Encrypt (plainFile, encFile)
99+ if err != nil {
100+ panic (err)
101+ }
83102```
84103
85- I haven't had the time to debug this further.
86104
87105[ releases ] : https://github.com/maxlaverse/synocrypto/releases
0 commit comments