Skip to content

DuckyMomo20012/file-crypto

Repository files navigation

File Crypto

A simple file storage console

contributors last update forks stars open issues license


πŸ“” Table of Contents

🌟 About the Project

πŸ“· Screenshots

screenshot

Last updated: Jun 27, 2022

screenshot

Last updated: Jun 24, 2022

πŸ‘Ύ Tech Stack

Client
Database

🎯 Features

  • πŸ”’οΈ Uploaded files are encrypted.
  • πŸ”‘ Password protection for files.
  • πŸ”οΈ Preview text file in terminal.
  • ✏️ File editor in the terminal.
  • 🎨 Syntax highlight for supporting formats.
  • 🧰 Toolbox:
    • πŸ“ Sign file.
    • βœ… Verify file signature.
    • πŸ”’ Encrypt the file.
    • πŸ”“ Decrypt the file.
  • πŸ‘€ (Preview feature) Preview image in terminal using ANSI codes.

🎨 Color Reference

This color palette is based on Nord theme.

Color Hex
nord0 #2E3440 #2E3440
nord1 #3B4252 #3B4252
nord2 #434C5E #434C5E
nord3 #4C566A #4C566A
nord4 #D8DEE9 #D8DEE9
nord5 #E5E9F0 #E5E9F0
nord6 #ECEFF4 #ECEFF4
nord7 #8FBCBB #8FBCBB
nord8 #88C0D0 #88C0D0
nord9 #81A1C1 #81A1C1
nord10 #5E81AC #5E81AC
nord11 #BF616A #BF616A
nord12 #D08770 #D08770
nord13 #EBCB8B #EBCB8B
nord14 #A3BE8C #A3BE8C
nord15 #B48EAD #B48EAD

πŸ”‘ Environment Variables

To run this project, you will need to add the following environment variables to your .env file:

  • MongoDB configs:

    MONGODB_HOST: An URI to connect to your database.

E.g:

# .env
MONGODB_HOST="mongodb+srv://{username}:{password}@crypto-file.9mziwnd.mongodb.net/test"

You can also check out the file .env.example to see all required environment variables.

🧰 Getting Started

‼️ Prerequisites

  • Python: >= 3.9.

  • Operating system: Linux and macOS.

    Note: This app only supports Linux and macOS. Currently not supporting Windows.

  • This project uses Poetry as package manager:

    Linux, macOS, Windows (WSL)

    curl -sSL https://install.python-poetry.org | python3 -

    Read more about installation on Poetry documentation.

πŸƒ Run Locally

Clone the project:

git clone https://github.com/DuckyMomo20012/file-crypto.git

Go to the project directory:

cd file-crypto

Install dependencies:

poetry install

OR:

Export Poetry dependencies to file requirements.txt:

poetry export -f requirements.txt --output requirements.txt

Note: You can add the option: --dev to include development dependencies.

Then install dependencies with pip:

pip install -r requirements.txt

Activate the virtual environment:

poetry shell

Start the program:

poe dev

OR:

python3 app.py

πŸ‘€ Usage

First, you have to log in to your account on the Login page:

Screenshot

login page

OR:

Create your new account on the Register page:

Screenshot

register page

Note: The email field must have a valid email format.

After login, you will see the Dashboard page:

dashboard page

  • Your files will be grouped into dates and sorted by date from newest to oldest.

  • Settings: You can see and edit your account information or change your password here.

    Screenshot

    settings page

    • Your information: This page will show you brief information about your account.

      Screenshot

      your information page

    • Edit your information page: You can edit your information here.

      Screenshot

      edit your information page

      Note: To edit your date of birth, your new value has to follow this format: YYYY-MM-DD. E.g: 2022-01-01.

    • Change password page:

      Screenshot

      change password page

    • Logout: This will log you out and redirect you to the Login page.

  • Tools: This consists of multiple helpful tools:

    Screenshot

    tools

    • Sign file: This tool will create a file with the .sig extension in your save folder path, which is your file's signature. Later, another user can use the Verify signed file tool to check who has signed that file.

      Screenshot

      sign file page

    • Verify signed file: This tool will check all available users to verify that file was signed by a valid user.

      Screenshot

      verify signed file page

    • Encrypt file: This tool will create a file with .bin extension in your save folder path. The only targeted receiver can decrypt that file using the Decrypt file tool.

      Note: You can target yourself as the receiver.

      Screenshot

      encrypt file page

    • Decrypt file: This tool will try to decrypt your encrypted and encode it if possible and save it to your save folder path.

      Screenshot

      decrypt file page

      Note: Encrypted file name MUST have .bin extension.

Note: The file path and folder path can be an absolute path or relative path. E.g:

./src/pages/
./
../
./../
/home/alice/Desktop/file-crypto
/home/alice/Desktop/file-crypto/

Note: Other fields without (optional) is required.

  • Upload: You can upload your file here. After uploading, your file will be encrypted.

    Screenshot

    upload file page

    Note: If you upload a file with the same name, the new file name will be appended with a timestamp. E.g: app_20220626221134.py.

  • File preview: After you type your password to unlock the file, the file will be opened in a window, in preview mode, and using the dracula theme by default (only available for text files).

    file preview page

    Note: Preview mode supports text files and images files. Edit mode only supports text files.

    • In Preview mode, you can change many themes if the file extension is supported since we use Pygments to enable syntax highlighting.

      Screenshot

      theme picker page

      Note: If your file type is not supported, you should change to the no theme theme.

      Note: Some themes will be removed due to incompatible: borland, lilypond, trac, bw, algol, algol_nu.

    • You can optionally switch to Edit mode with the Edit mode button:

      edit mode page

      Note: Any changes with "newlines" ("\n"), "tabs" ("\t") or "whitespace" (" ") will be consider as "no changes", and won't be saved.

    • You can also can Download this file to your computer or Delete this file.

      Note: Delete will completely delete the file from the server.

    • File information: You can see brief information about your file.

      Screenshot

      file information page

    • Edit file information: You can edit your file name here.

      Screenshot

      edit file information page

    • (Preview feature) Preview image file: Using CLImage to display beautiful pictures using ANSI codes.

      image preview page

      Note: This is a preview feature. This feature may reduce your computer performance.

πŸ”§ Settings

You can override default behaviors by configuring the settings.json file.

Name Description Default
workbench.preview.defaultColorTheme The default theme for file preview mode 'dracula'
workbench.preview.imageWidth Default image width for image preview mode 60
workbench.preview.defaultMode Default mode for preview page. Options: preview, edit preview
workbench.animation Controls if animation is played when adding or removing windows true
workbench.styles Load default styles to the application [object Object]

Note: workbench.animation setting not apply to modals (error, success, warning) or toast messages.

Note: workbench.styles will simply dump JSON to YAML and load them to the application. The default value for this setting is loaded from the file styles.yaml.

πŸ‘ Application Styles

You can customize your application looks (text colors, border chars,...) by changing default styles in file styles.yaml.

Read more about customizing on PyTermGUI documentation.

🧭 Roadmap

  • Share files with other users.
    • Download shared files.
    • "Shared with me" tab to view shared files.
    • File permission level. E.g: read-only, write,...
    • Edit shared files.
  • Apply themes for editing mode.
  • Trash can store temporarily deleted files.
  • Preview mode for images.
  • Image size automatically resizes on window resize in preview mode.
  • Config default theme in user settings.
  • Config testing.

πŸ‘‹ Contributing

Contributions are always welcome!

πŸ“œ Code of Conduct

Please read the Code of Conduct.

❔ FAQ

  • Is this project still maintained?

    • Yes, but we will only update UI, docs, or dependencies. New features won't be added frequently.
  • Is this project ready for production?

    • No, this is a small project for practicing cryptographic systems or schemes. This wasn't meant for production.
  • Are you planning to support Windows OS in the future?

    • No, we are not adding support for Windows any time soon (and most likely never).
  • Error: IndexError: list index out of range:

    • Please update PyTermGUI to version 7.0.0 or higher to resolve this issue.
  • Error: assert self._drag_start is not None:

    • Please update PyTermGUI to version 7.0.0 or higher to resolve this issue.
  • Error: ValueError: list.remove(x): x not in list:

    • You are clicking the button too fast before the modal or window is fully closed. You should click the button once and wait for the modal or window is fully closed.
  • In image preview mode, my image is broken:

    • That is because your terminal width size is too small. Image has a default width size is 60 block. The terminal should be larger than that size (the nav bar wasn't counted).
  • I can't decrypt my file using the Decrypt file tool:

    • Maybe the encrypted file is broken. You should ask the owner to resend the file.
  • In preview mode for large text files, the app becomes very laggy:

    • Then you should change to the no theme theme.
  • I have accidentally deleted the file, how can I restore it?

    • No, you can't. If the file is deleted, it will be completely deleted from our database and can't be restored.
  • I can't load settings using the settings.json file:

    • Ensure your JSON format is correct. Notice that comment is not allowed in JSON files.

    • For application styles, make sure those styles are supported.

⚠️ License

Distributed under MIT license. See LICENSE for more information.

🀝 Contact

Duong Vinh - @duckymomo20012 - tienvinh.duong4@gmail.com

Project Link: https://github.com/DuckyMomo20012/file-crypto.

πŸ’Ž Acknowledgements

Here are useful resources and libraries that we have used in our projects:

  • PyTermGUI: A wonderful and fully documented TUI framework to make your terminal rocks.
  • Pygments: A useful utility to add your favorite theme to your code.
  • CLImage: Print out magnificent pictures in your terminal using ANSI codes.
  • Awesome Readme Template: A detailed template to bootstrap your README file quickly.