{"id":29082487,"url":"https://github.com/iharkatkavets/fcrypt","last_synced_at":"2025-06-27T20:37:52.273Z","repository":{"id":263322002,"uuid":"889983085","full_name":"iharkatkavets/fcrypt","owner":"iharkatkavets","description":"A command-line tool for encrypting and decrypting files using the XChaCha20 algorithm. ","archived":false,"fork":false,"pushed_at":"2025-06-27T19:30:23.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-27T20:31:12.724Z","etag":null,"topics":["file-encryption","sha256","xchacha20"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iharkatkavets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-17T18:15:56.000Z","updated_at":"2025-06-27T19:30:29.000Z","dependencies_parsed_at":"2025-02-22T21:20:28.870Z","dependency_job_id":"e0eb0d67-766b-47bf-94fd-dfae6264a878","html_url":"https://github.com/iharkatkavets/fcrypt","commit_stats":null,"previous_names":["iharkatkavets/secure-encryptor","iharkatkavets/fcrypt"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/iharkatkavets/fcrypt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iharkatkavets%2Ffcrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iharkatkavets%2Ffcrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iharkatkavets%2Ffcrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iharkatkavets%2Ffcrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iharkatkavets","download_url":"https://codeload.github.com/iharkatkavets/fcrypt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iharkatkavets%2Ffcrypt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262330157,"owners_count":23294862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-encryption","sha256","xchacha20"],"created_at":"2025-06-27T20:37:34.275Z","updated_at":"2025-06-27T20:37:52.261Z","avatar_url":"https://github.com/iharkatkavets.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fcrypt\r\n\r\nA command-line tool for encrypting and decrypting files using the XChaCha20 algorithm.\r\n\r\n## Supported platforms\r\n\r\nAt the moment it supports macOS only\r\n\r\n## How to encrypt the file\r\n\r\n```bash\r\n./bin/fcrypt -e origin.file -o encrypted.file \r\n```\r\n\r\n## How to decrypt the file\r\n\r\n```bash\r\n./bin/fcrypt -d encrypted.file -o decrypted.file\r\n./bin/fcrypt -d encrypted.file\r\n```\r\n\r\n## Arguments and Parameters\r\n\r\n- **`-e \u003cFILE\u003e`, `--encrypt \u003cFILE\u003e`**  \r\n  Encrypts the input file. The password will be prompted  \r\n  _Example:_ `fcrypt -e origin.file -o encrypted.file`\r\n\r\n- **`-P \u003cSIZE\u003e`, `--padsize \u003cSIZE\u003e`**  \r\n  The pad size. Must be in range [0,65535]. Taken random size if\r\n  not provided.  \r\n  _Example:_ `fcrypt -e origin.file -P 16 -o encrypted.file`\r\n\r\n- **`-p \u003cPASSWORD\u003e`, `--password \u003cPASSWORD\u003e`**  \r\n  The password of len up 256 characters.  \r\n  _Example:_ `fcrypt -e origin.file -k 'password' -o encrypted.file`  \r\n  _Example:_ `fcrypt -d encrypted.file -k 'password'`\r\n\r\n- **`-i \u003chint\u003e`, `--hint \u003cHINT\u003e`**  \r\n  The hint to remember the password  \r\n  _Example:_ `fcrypt -e origin.file -i 'hint' -o encrypted.file`  \r\n  _Example:_ `fcrypt -d encrypted.file`\r\n\r\n- **`-o`, `--output \u003cFILE\u003e`**  \r\n  The output file with encrypted content  \r\n  _Example:_ `fcrypt -e origin.file -o encrypted.file`  \r\n  _Example:_ `fcrypt -d encrypted.file -o origin.file`\r\n\r\n- **`-d`, `--decrypt`**  \r\n  Decrypts the input file. The password will be prompted  \r\n  _Example:_ `fcrypt -d encrypted.file`\r\n\r\n- **`-n`, `--nohint`**  \r\n  Don't request to input hint  \r\n  _Example:_ `fcrypt -n -e origin.file -o encrypted.file`\r\n\r\n- **`-v`, `--verbose`**  \r\n  Add more output  \r\n  _Example:_ `fcrypt -v -e origin.file -o encrypted.file`\r\n\r\n- **`-V`**  \r\n  Print version number and exit  \r\n  _Example:_ `fcrypt -V`\r\n\r\n- **`-h`, `--help`**  \r\n  Print help  \r\n  _Example:_ `fcrypt -h`\r\n\r\n## How to compile the project\r\n\r\n```bash\r\ngit clone https://github.com/iharkatkavets/secure-encryptor.git \u0026\u0026 cd secure-encryptor\r\nmake all\r\n# Binary files located in bin dir\r\nls ./bin\r\n```\r\n\r\n## Encrypted file format\r\n\r\nXChaCha20 operates with a 256-bit key and a 192-bit nonce. It is safe to place\r\nthe nonce at the beginning of the encrypted file. The hash of the key(password)\r\nis located after the padded bytes.\r\nAll content except HINT_LEN, PASSWORD HINT, NONCE is encrypted using XChaCha20 algorithm.\r\n\r\n```text\r\n                              ↓ ENCRYPTED FILE FORMAT ↓                      \r\n+---------+----------+----------------+---------------+-----------+----------------+-----------+-----------+\r\n| 2 bytes | 2 bytes  | HINT_LEN bytes |   24 bytes    |  2 bytes  | PAD_SIZE bytes | 32 bytes  | ...       |\r\n+---------+----------+----------------+---------------+-----------+----------------+-----------+-----------+\r\n| FORMAT  | HINT_LEN | NON ENCRYPTED  | NON ENCRYPTED | RANDOM    |  ENCRYPTED     | ENCRYPTED | ENCRYPTED |\r\n| VERSION |          | PASSWORD HINT  | NONCE (IV)    | ENCRYPTED |  PADDING       | KEY HASH  | SRC FILE  |   \r\n|   LE    |          |                |               | PAD_SIZE  |  BYTES         | (SHA256)  |           |\r\n+---------+----------+----------------+---------------+-----------+----------------+-----------+-----------+\r\n```\r\n\r\n**FORMAT_VERSION (2 bytes, little endian):**\r\n• Stores version of the format used\r\n\r\n**NON_ENCRYPTED_NONCE (24 bytes):**  \r\n• Stores the 192-bit nonce.  \r\n• The nonce is uniquely generated for every encryption operation using the same\r\nkey. It is non-sensitive and can be safely stored without encryption.\r\n\r\n**ENCRYPTED_PAD_SIZE (2 bytes):**  \r\n• Contains the size of random padding bytes in the file, encrypted to hide\r\npotential file structure hints.  \r\n• 2 bytes (16 bits) allow for a maximum pad size of 65,535 bytes, which should\r\nbe sufficient.\r\n\r\n**ENCRYPTED_RANDOM_BYTES (PAD_SIZE bytes):**  \r\n• Random padding added to prevent file size inference attacks.  \r\n• These bytes are encrypted to prevent exposing the padding length directly.  \r\n\r\n**ENCRYPTED_KEY_HASH (32 bytes):**  \r\n• A 256-bit hash of the encryption key, encrypted with the key itself.  \r\n• This allows verification that the correct key is being used during decryption.\r\n\r\n**ENCRYPTED_FILE (FILE_SIZE bytes):**  \r\n• The encrypted main payload.\r\n\r\n## Inspirations and Contributions\r\n\r\nThis project draws inspiration from the video lectures of [Dr. Jonas\r\nBirch](https://www.linkedin.com/in/jonasbirch/). The concept for the encrypted\r\nfile format adapts ideas presented in those lectures.\r\n\r\nAdditionally, sources from the repository\r\n[vitorstraggiotti/easySHA256](https://github.com/vitorstraggiotti/easySHA256)\r\nwere utilized to implement SHA256.\r\n\r\nAnd sources from the repository\r\n[spcnvdr/xchacha20](https://github.com/spcnvdr/xchacha20) were utilized to\r\nimplement XChaCha20.\r\n\r\n## License\r\n\r\n```txt\r\nMIT License\r\n\r\nCopyright (c) 2024 Ihar Katkavets\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n```\r\n\r\nThis project also includes code from\r\n[spcnvdr/xchacha20](https://github.com/spcnvdr/xchacha20) by Bryan Hawkins,\r\nlicensed under the BSD-3-Clause License:\r\n\r\n```txt\r\nCopyright 2019 Bryan Hawkins \u003cspcnvdrr@protonmail.com\u003e\r\n\r\nRedistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions\r\nare met:\r\n\r\n1. Redistributions of source code must retain the above copyright notice,\r\nthis list of conditions and the following disclaimer.\r\n\r\n2. Redistributions in binary form must reproduce the above copyright\r\nnotice, this list of conditions and the following disclaimer in the\r\ndocumentation and/or other materials provided with the distribution.\r\n\r\n3. Neither the name of the copyright holder nor the names of its\r\ncontributors may be used to endorse or promote products derived from\r\nthis software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\nHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiharkatkavets%2Ffcrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiharkatkavets%2Ffcrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiharkatkavets%2Ffcrypt/lists"}