A Go library to decrypt/encrypt Synology Cloud Sync files on various Operating Systems (Linux, macOS, Windows).
The file format was originally discovered by @marnix and is summarized in this document.
Assuming you have the go toolchain installed:
go install github.com/maxlaverse/synocrypto/cli/synocrypto
You can also download pre-compiled binaries from the releases page.
NAME:
synocrypto - A cli for encrypting and decrypting Synology Cloud Sync files
USAGE:
synocrypto [global options] command [command options] [arguments...]
COMMANDS:
decrypt, d Decrypts a file
encrypt, e Encrypts a file
metadata, m Displays the metadata of a file
version Prints the version
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--debug outputs additional debug lines (default: false)
--help, -h show help (default: false)
encFile, err := os.Open("./my-encrypted-file.jpg")
if err != nil {
panic(err)
}
defer encFile.Close()
decFile, err := os.OpenFile("./my-decrypted-file.jpg", os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
defer decFile.Close()
decrypter := synocrypto.NewDecrypter(synocrypto.DecrypterOptions{
Password: "synocrypto",
})
err = decrypter.Decrypt(encFile, decFile)
if err != nil {
panic(err)
}
plainFile, err := os.Open("./my-plain-file.jpg")
if err != nil {
panic(err)
}
defer plainFile.Close()
encFile, err := os.OpenFile("./my-encrypted-file.jpg", os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
defer encFile.Close()
privateKey, err := ioutil.ReadFile("private.pem")
if err != nil {
panic(err)
}
encrypter := synocrypto.NewEncrypter(synocrypto.EncrypterOptions{
Password: "synocrypto",
PrivateKey: privateKey,
})
err = encrypter.Encrypt(plainFile, encFile)
if err != nil {
panic(err)
}