From 2bca147e3d9d4f4ed4cfb0d3fdbc1fe58ce29c63 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Fri, 10 Feb 2023 21:51:08 +0800 Subject: [PATCH] feat: update readme --- README.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c25f8eb..9563ecf 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,92 @@ Debug logging: ```shell $ java -jar -Dcommons.log.debug=true tiny-encrypt.jar ... -``` \ No newline at end of file +``` + +Encrypt file: + +```shell +$ tiny-encrypt -e test.txt +[INFO] Start processing file: test.txt, 1 of 1 +[INFO] Get data key from kms, key name: prod_ec_key, with sign: false ... +Encrypting, Processed: 12, Speed: 2.93KB/s +[INFO] Encrypt file success: test.txt +``` + +> Skip envelop data key: `--skip-envelop` + +Show encrypted file info: + +```shell +$ tiny-encrypt -I test.txt.tinyenc +[INFO] Tiny Encrypt File Info +File..............: test.txt.tinyenc +File size.........: 12 byte(s) +Enc file summary..: Version: 1.0, Agent: TinyEncrypt v0.5.1@MacOS +Last modified.....: Fri Feb 10 00:50:07 CST 2023 +Enc file created..: Fri Feb 10 01:16:12 CST 2023 +Envelops..........: KMS: YES, PGP: YES +PGP fingerprint...: de5a99c239a82adf039982cb6319abcb95f44cfc76a5027ae6f7819cfc5fde7c +Encrypted comment.: NO +``` + +Decrypt file: + +```shell +$ tiny-encrypt -d test.txt.tinyenc +[INFO] Start processing file: test.txt.tinyenc, 1 of 1 +[INFO] Start: /Users/hatterjiang/.cargo/bin/card-cli +[INFO] Finished command +[INFO] Decrypt local private key success! +[INFO] Decrypt data key ... +Decrypting, Processed: 12, Speed: 3.91KB/s +[INFO] Decrypt file success: test.txt.tinyenc +``` + +Decrypt file with OpenPGP card: + +```shell +$ tiny-encrypt -d --pgp test.txt.tinyenc +[INFO] Start processing file: test.txt.tinyenc, 1 of 1 +Input PGP user PIN: +[INFO] Start: /Users/hatterjiang/.cargo/bin/card-cli +[INFO] Finished command +Decrypting, Processed: 12, Speed: 2.93KB/s +[INFO] Decrypt file success: test.txt.tinyenc +``` + +Use alias: + +```shell +alias tiny-encrypt='java -jar ~/bin/tiny-encrypt.jar' +alias tiny-encrypt-debug='java -jar -Dcommons.log.debug=true ~/bin/tiny-encrypt.jar' +``` + +File ext: `*.tinyenc` + +File format: + +```text +[TAG; 2 bytes; short; BE] +[LENGTH; 4 bytes; int; BE] +[META; LENGTH bytes] +[ENCRYPTED_DATA; n bytes; AES/GCM] +``` + +Meta format: + +| Field | Type | Comment | +|---------|---------|---------------------------------------------| +| version | String | Constant value: `1.0` | +| created | Long | Created time, Unix Epoch | +| userAgent | String | User Agent, e.g. `TinyEncrypt v0.5.1@MacOS` | +| comment | String | Plain text comment | +| encryptedComment | String | Encrypted comment | +| pgpEnvelop | String | PGP Publickey Encrypted DataKey | +| pgpFingerprint | String | Hex(Sha256(PGP Publickey)) | +| envelop | String | KMS Encrypted DataKey | +| nonce | byte[] | GCM Nonce | +| fileLength | Long | File Length | +| fileLastModified | Long | File Last Modified | +| compress | Boolean | Compress or not | +