https://github.com/duckymomo20012/file-crypto
Encrypted file storing
https://github.com/duckymomo20012/file-crypto
climage mongodb pygments pytermgui python3
Last synced: about 1 month ago
JSON representation
Encrypted file storing
- Host: GitHub
- URL: https://github.com/duckymomo20012/file-crypto
- Owner: DuckyMomo20012
- License: mit
- Created: 2022-06-06T14:21:42.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-13T05:37:09.000Z (over 3 years ago)
- Last Synced: 2025-03-26T04:15:01.759Z (about 1 year ago)
- Topics: climage, mongodb, pygments, pytermgui, python3
- Language: Python
- Homepage:
- Size: 354 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
File Crypto
A simple file storage console
View Demo
ยท
Documentation
ยท
Report Bug
ยท
Request Feature
# :notebook_with_decorative_cover: Table of Contents
- [About the Project](#star2-about-the-project)
- [Screenshots](#camera-screenshots)
- [Tech Stack](#space_invader-tech-stack)
- [Features](#dart-features)
- [Color Reference](#art-color-reference)
- [Environment Variables](#key-environment-variables)
- [Getting Started](#toolbox-getting-started)
- [Prerequisites](#bangbang-prerequisites)
- [Run Locally](#running-run-locally)
- [Usage](#eyes-usage)
- [Settings](#wrench-settings)
- [Application Styles](#peach-application-styles)
- [Roadmap](#compass-roadmap)
- [Contributing](#wave-contributing)
- [Code of Conduct](#scroll-code-of-conduct)
- [FAQ](#grey_question-faq)
- [License](#warning-license)
- [Contact](#handshake-contact)
- [Acknowledgements](#gem-acknowledgements)
## :star2: About the Project
### :camera: Screenshots
_Last updated: Jun 27, 2022_
_Last updated: Jun 24, 2022_
### :space_invader: Tech Stack
Client
Database
### :dart: 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.
### :art: Color Reference
This color palette is based on [Nord](https://www.nordtheme.com/) theme.
| Color | Hex |
| ------ | ---------------------------------------------------------------- |
| nord0 |  #2E3440 |
| nord1 |  #3B4252 |
| nord2 |  #434C5E |
| nord3 |  #4C566A |
| nord4 |  #D8DEE9 |
| nord5 |  #E5E9F0 |
| nord6 |  #ECEFF4 |
| nord7 |  #8FBCBB |
| nord8 |  #88C0D0 |
| nord9 |  #81A1C1 |
| nord10 |  #5E81AC |
| nord11 |  #BF616A |
| nord12 |  #D08770 |
| nord13 |  #EBCB8B |
| nord14 |  #A3BE8C |
| nord15 |  #B48EAD |
### :key: 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.
## :toolbox: Getting Started
### :bangbang: 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](https://python-poetry.org/) as package manager:
Linux, macOS, Windows (WSL)
```bash
curl -sSL https://install.python-poetry.org | python3 -
```
Read more about installation on
[Poetry documentation](https://python-poetry.org/docs/master/#installation).
### :running: Run Locally
Clone the project:
```bash
git clone https://github.com/DuckyMomo20012/file-crypto.git
```
Go to the project directory:
```bash
cd file-crypto
```
Install dependencies:
```bash
poetry install
```
OR:
Export Poetry dependencies to file `requirements.txt`:
```bash
poetry export -f requirements.txt --output requirements.txt
```
> **Note**: You can add the option: `--dev` to include development dependencies.
Then install dependencies with `pip`:
```bash
pip install -r requirements.txt
```
---
Activate the virtual environment:
```bash
poetry shell
```
Start the program:
```bash
poe dev
```
OR:
```bash
python3 app.py
```
## :eyes: Usage
First, you have to log in to your account on the **Login** page:
Screenshot

OR:
Create your new account on the **Register** page:
Screenshot

> **Note**: The email field must have a valid email format.
After login, you will see the **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

- **Your information**: This page will show you brief information about your
account.
Screenshot

- **Edit your information** page: You can edit your information here.
Screenshot

> **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

- **Logout**: This will log you out and redirect you to the **Login** page.
- **Tools**: This consists of multiple helpful tools:
Screenshot

- **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

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

- **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

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

> **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

> **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).

> **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](https://pygments.org/) to enable syntax
highlighting.
Screenshot

- You can turn off syntax highlighting by choosing `no theme` in the theme
picker.
- All supported file types: https://pygments.org/docs/lexers/
> **Note**: If your file type is not supported, you should change to the `no theme` theme.
- All available themes: https://pygments.org/styles/
> **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:

> **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

- **Edit file information**: You can edit your file name here.
Screenshot

- **(Preview feature) Preview image file**: Using
[CLImage](https://github.com/pnappa/CLImage) to display beautiful pictures
using ANSI codes.

> **Note**: This is a preview feature. This feature may reduce your computer
> performance.
## :wrench: 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`.
## :peach: 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](https://ptg.bczsalba.com/pytermgui.html#how-to-configure-your-application-using-yaml).
## :compass: 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.
- [x] Preview mode for images.
- [ ] Image size automatically resizes on window resize in preview mode.
- [x] Config default theme in user settings.
- [ ] Config testing.
## :wave: Contributing
Contributions are always welcome!
### :scroll: Code of Conduct
Please read the [Code of Conduct](https://github.com/DuckyMomo20012/file-crypto/blob/main/CODE_OF_CONDUCT.md).
## :grey_question: 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.
## :warning: License
Distributed under MIT license. See
[LICENSE](https://github.com/DuckyMomo20012/file-crypto/blob/main/LICENSE) for
more information.
## :handshake: Contact
Duong Vinh - [@duckymomo20012](https://twitter.com/duckymomo20012) -
tienvinh.duong4@gmail.com
Project Link: [https://github.com/DuckyMomo20012/file-crypto](https://github.com/DuckyMomo20012/file-crypto).
## :gem: Acknowledgements
Here are useful resources and libraries that we have used in our projects:
- [PyTermGUI](https://ptg.bczsalba.com/pytermgui.html): A wonderful and fully
documented TUI framework to make your terminal rocks.
- [Pygments](https://pygments.org/): A useful utility to add your favorite theme
to your code.
- [CLImage](https://github.com/pnappa/CLImage): Print out magnificent pictures
in your terminal using ANSI codes.
- [Awesome Readme Template](https://github.com/Louis3797/awesome-readme-template):
A detailed template to bootstrap your README file quickly.