A Racket program to decrypt files encrypted with Synology Cloudsync

Posted on Dec 31, 2022

I’ve been playing with Racket for the past few weeks.

While I haven’t explored all the language-oriented-programming aspects yet, I’ve created a simple program to decrypt files encrypted with Synology Cloudsync. It is available as synology-decrypt (The Racket version).

As I’ve written before, I use Backblaze to backup files to the cloud. My Synology NAS encrypts these files before uploading them using Cloudsync. The decryption software is not open source, and is a Windows and macOS-only GUI app. My version can run on any platform. The decryption scheme was reverse engineered by Marnix Klooster in their Python program of the same name. My contribution is:

  1. Porting it to Racket, and
  2. Documenting the file format.

It was a good exercise in using the I/O and crypto libraries in Racket, which were extremely well designed and easy to use. Racket is an exceptionally well designed and well documented language that doesn’t seem to get as much love in professional engineering circles as it should.

The only slightly smart thing it does is to choose between a Racket-native LZ4 decoder or using the C program based on file size. That’s because for really small files, spawning the new process takes longer than using the Racket-native decoder. For large files, the C program is currently orders of magnitude faster. Bogdan Popa has been an absolute champ at optimizing the lz4-lib package. As of version 1.3, the Racket implementation is only ~20% slower than the original lz4!1

I still need to figure out how to package this for Windows and macOS, as well as automating releases via Github actions.

Meanwhile, the README explains how to use it.

  1. Tested on a 450M file. ↩︎