# tiny-encrypt-java Tiny encrypt implemented by Java Debug logging: ```shell $ java -jar -Dcommons.log.debug=true tiny-encrypt.jar ... ``` 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 ``` Create file from text window: ```shell $ tiny-encrypt --create FILE ``` Show file in text window: ```shell $ tiny-encrypt -d --show FILE.tinyenc ``` Edit file in text window: ```shell $ tiny-encrypt -d --edit FILE.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; Always 1] [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 |