Skip to content

Commit

Permalink
chore: update readme and benchmark results
Browse files Browse the repository at this point in the history
  • Loading branch information
mrf345 committed Sep 13, 2024
1 parent e39df6e commit 4f9e61e
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 126 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ safelock-cli
</a>
</h1>

Fast files encryption (AES-GCM) package and command-line tool built for speed with Go and [Archiver](https://github.com/mholt/archiver)
Fast files encryption package and command-line tool built for speed with Go and [Archiver](https://github.com/mholt/archiver)

Utilizing `argon2id` and `chacha20poly1305` for encryption, see [default options](#options).


### Install

Expand All @@ -27,6 +30,7 @@ go get https://github.com/mrf345/safelock-cli@latest

Or using one of the latest release binaries [here](https://github.com/mrf345/safelock-cli/releases)


### Examples

Encrypt a path with default options
Expand All @@ -48,10 +52,21 @@ echo "password123456" | safelock-cli encrypt path_to_encrypt encrypted_file_path

You can find interactive examples of using it as a package to [encrypt](https://pkg.go.dev/github.com/mrf345/safelock-cli/safelock#example-Safelock.Encrypt) and [decrypt](https://pkg.go.dev/github.com/mrf345/safelock-cli/safelock#example-Safelock.Decrypt).

### Performance

- Encryption should be about **20.2** times faster than `gpgtar`, and the decryption **3.3** times.
- Encryption should be about **9.1** times faster than `7zip`, and the decryption **9.5** times.
### Options

Following the default options remanded by [RFC9106](https://datatracker.ietf.org/doc/html/rfc9106#section-7.4) and [crypto/argon2](https://pkg.go.dev/golang.org/x/crypto/argon2#IDKey)

| Option | Value |
|-------------------------|---------------------------------------------|
| Iterations | 3 |
| Memory size | 64 Megabytes |
| Key length | 32 |
| Threads | Number of available cores `runtime.NumCPU()`|
| Minimum password length | 8 |


### Performance

> [!NOTE]
> You can reproduce the results by running [bench_and_plot.py](benchmark/bench_and_plot.py) (based on [Matplotlib](https://github.com/matplotlib/matplotlib) and [Hyperfine](https://github.com/sharkdp/hyperfine))
Expand Down
Binary file modified benchmark/decryption-time.webp
Binary file not shown.
102 changes: 41 additions & 61 deletions benchmark/decryption.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"results": [
{
"command": "echo \"123456789\" | ~/Projects/safelock-cli/safelock-cli decrypt test.sla safelock_dump --quiet",
"mean": 2.1295176539933336,
"stddev": 0.03361454776096437,
"median": 2.13093239266,
"user": 2.5876522466666665,
"system": 1.88427306,
"min": 2.0952180726600003,
"max": 2.16240249666,
"mean": 1.8276349158133336,
"stddev": 0.14566191806696024,
"median": 1.9042654354800002,
"user": 2.309450346666667,
"system": 1.9107805599999999,
"min": 1.6596538664800002,
"max": 1.9189854454800002,
"times": [
2.16240249666,
2.13093239266,
2.0952180726600003
1.9189854454800002,
1.9042654354800002,
1.6596538664800002
],
"exit_codes": [
0,
Expand All @@ -21,38 +21,18 @@
]
},
{
"command": "echo \"123456789\" | ~/Projects/safelock-cli/safelock-cli decrypt test_sha256.sla safelock_dump --quiet --sha256",
"mean": 1.8789916449933333,
"stddev": 0.17816416646803604,
"median": 1.98184108566,
"user": 2.0644982466666666,
"system": 1.776121393333333,
"min": 1.67326538666,
"max": 1.9818684626599998,
"command": "sleep 0.05; xdotool type \"123456789\"; xdotool key \"Return\" | age --decrypt test.age | tar x --zstd -f - -C safelock_dump",
"mean": 2.816656686146667,
"stddev": 0.2702910723941267,
"median": 2.9378343294800002,
"user": 2.6122993466666666,
"system": 5.240392226666667,
"min": 2.50698103648,
"max": 3.00515469248,
"times": [
1.67326538666,
1.98184108566,
1.9818684626599998
],
"exit_codes": [
0,
0,
0
]
},
{
"command": "echo \"123456789\" | ~/Projects/safelock-cli/safelock-cli decrypt test_sha512.sla safelock_dump --quiet --sha512",
"mean": 2.123450407993334,
"stddev": 0.1763774710740607,
"median": 2.1136010126600002,
"user": 2.5975039133333335,
"system": 1.7468127266666666,
"min": 1.95220401166,
"max": 2.3045461996600003,
"times": [
2.3045461996600003,
2.1136010126600002,
1.95220401166
3.00515469248,
2.9378343294800002,
2.50698103648
],
"exit_codes": [
0,
Expand All @@ -62,17 +42,17 @@
},
{
"command": "7z e -y -p123456789 -mx1 test.7z -osafelock_dump",
"mean": 17.944166026326666,
"stddev": 0.03535223844853417,
"median": 17.95858265166,
"user": 19.665792913333334,
"system": 1.4092493933333332,
"min": 17.90388353266,
"max": 17.97003189466,
"mean": 18.76303972514667,
"stddev": 0.10991428273642811,
"median": 18.72587103648,
"user": 20.692533679999997,
"system": 1.3673248933333333,
"min": 18.67652879848,
"max": 18.886719340480003,
"times": [
17.97003189466,
17.90388353266,
17.95858265166
18.67652879848,
18.886719340480003,
18.72587103648
],
"exit_codes": [
0,
Expand All @@ -82,17 +62,17 @@
},
{
"command": "gpgtar -d --yes --batch --gpg-args \"--passphrase 123456789\" test.gpg",
"mean": 6.240754918993335,
"stddev": 0.18841334623779463,
"median": 6.18021860166,
"user": 0.17699391333333328,
"system": 1.4514090599999998,
"min": 6.09005041466,
"max": 6.45199574066,
"mean": 6.573486912813334,
"stddev": 0.3839886822791872,
"median": 6.52200845048,
"user": 0.21511468,
"system": 1.4525625599999998,
"min": 6.21783424048,
"max": 6.98061804748,
"times": [
6.45199574066,
6.18021860166,
6.09005041466
6.98061804748,
6.52200845048,
6.21783424048
],
"exit_codes": [
0,
Expand Down
Binary file modified benchmark/encryption-time.webp
Binary file not shown.
102 changes: 41 additions & 61 deletions benchmark/encryption.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"results": [
{
"command": "echo \"123456789\" | ~/Projects/safelock-cli/safelock-cli encrypt Videos test.sla --quiet",
"mean": 2.2742533827266667,
"stddev": 0.05119318397940522,
"median": 2.28937216306,
"user": 3.329233973333333,
"system": 1.3630514999999999,
"min": 2.21720349906,
"max": 2.31618448606,
"mean": 2.915796215026667,
"stddev": 0.6152785400365611,
"median": 2.59659688136,
"user": 2.9221347666666673,
"system": 1.8123637266666666,
"min": 2.52571277236,
"max": 3.62507899136,
"times": [
2.21720349906,
2.31618448606,
2.28937216306
3.62507899136,
2.59659688136,
2.52571277236
],
"exit_codes": [
0,
Expand All @@ -21,38 +21,18 @@
]
},
{
"command": "echo \"123456789\" | ~/Projects/safelock-cli/safelock-cli encrypt Videos test_sha256.sla --quiet --sha256",
"mean": 2.2029850927266668,
"stddev": 0.2887786765513728,
"median": 2.29156615106,
"user": 3.45133264,
"system": 1.3318238333333332,
"min": 1.88029167006,
"max": 2.43709745706,
"command": "tar cv --zstd Videos | . /home/mrf3/Projects/safelock-cli/benchmark/pipe_age_password.sh | age -e -p -o test.age",
"mean": 3.5844030323599996,
"stddev": 0.8456093581031698,
"median": 3.99741505136,
"user": 3.664084433333333,
"system": 4.025338726666667,
"min": 2.61165881536,
"max": 4.14413523036,
"times": [
2.43709745706,
1.88029167006,
2.29156615106
],
"exit_codes": [
0,
0,
0
]
},
{
"command": "echo \"123456789\" | ~/Projects/safelock-cli/safelock-cli encrypt Videos test_sha512.sla --quiet --sha512",
"mean": 2.3804781427266666,
"stddev": 0.2607000393652314,
"median": 2.29337213106,
"user": 3.7844909733333325,
"system": 1.4182584999999996,
"min": 2.17448372306,
"max": 2.67357857406,
"times": [
2.67357857406,
2.17448372306,
2.29337213106
2.61165881536,
3.99741505136,
4.14413523036
],
"exit_codes": [
0,
Expand All @@ -62,17 +42,17 @@
},
{
"command": "7z a -p123456789 -mx1 test.7z Videos",
"mean": 20.227981493393333,
"stddev": 0.47311415510031346,
"median": 20.17403875506,
"user": 137.52122964,
"system": 0.9545411666666667,
"min": 19.78415073906,
"max": 20.72575498606,
"mean": 20.89819147436,
"stddev": 0.521090452676126,
"median": 20.99556633936,
"user": 144.56984343333332,
"system": 1.0643993933333333,
"min": 20.33528243436,
"max": 21.36372564936,
"times": [
20.72575498606,
20.17403875506,
19.78415073906
21.36372564936,
20.33528243436,
20.99556633936
],
"exit_codes": [
0,
Expand All @@ -82,17 +62,17 @@
},
{
"command": "gpgtar -e -o test.gpg -c --yes --batch --gpg-args \"--passphrase 123456789\" Videos",
"mean": 44.902245365726664,
"stddev": 1.3460233818310492,
"median": 44.85683033906,
"user": 33.18701430666666,
"system": 9.421267166666667,
"min": 43.57950423606,
"max": 46.27040152206,
"mean": 44.73956679669333,
"stddev": 3.0879084948438327,
"median": 44.51365098336,
"user": 34.082144766666666,
"system": 9.58027806,
"min": 41.77082056336,
"max": 47.93422884336,
"times": [
46.27040152206,
43.57950423606,
44.85683033906
44.51365098336,
47.93422884336,
41.77082056336
],
"exit_codes": [
0,
Expand Down
Binary file modified benchmark/file-size.webp
Binary file not shown.

0 comments on commit 4f9e61e

Please sign in to comment.