Cipher Web Service
Encrypt and decrypt messages with your own custom rules - POTATOMATO
๐๏ธ ๋ง๋ ์ด์
'๋ฆด๋ฆฌ์์์ ๋ชจ๋ ๊ฒ'์์ ๋ฆด๋ฆฌ์ด๋ฅผ ๋ณด๊ณ ๋ฉ์ง๋ค๊ณ ์๊ฐํ๋ค.
๋๋ฌด์ํค์์ ๋๊ฐ ๋ฆด๋ฆฌ์ด ๋ฒ์ญ ํ๋ก๊ทธ๋จ์ ๋ง๋ค์ด๋์ ๊ฒ์ ๋ดค๋ ๊ฒ ๊ฐ๋ค.
๋ง์นจ ๋๋ ๊ธฐ๋ก์ ํ๊ณ ์๋๋ฐ, ๋ค๋ฅธ ์ฌ๋์ด ์ฝ์ง๋ ๋ชปํ์ผ๋ฉดํด์ ๊ทธ๋ฐ ์ํธํ ํ๋ก๊ทธ๋จ์ ๋ง๋ค์๋ค.
๐ข Project ์ค๋ช
๐ Notes on a conditional form
N.O.C.F is an easy and fun web application for encrypting and decrypting text. This site helps users keep their text confidential and communicate securely with others.
Key Features:
Text Encryption: Encrypt your input text using the chosen encryption algorithm. The encrypted text can be safely stored or shared.
Text Decryption: Restore the original text from the encrypted text. The key or algorithm used during encryption is required.
Secret Notes: Encrypt personal notes to keep them secure.
Use Cases:
Secret Messages: Send confidential messages to friends or family.
Protect Personal Notes: Encrypt important personal notes for safe storage.
๐ฅ Site Demo

๐
๐ป Tech Stack
Flask(Python), PostgreSQL, React(Javascript), Docker
Time : 4hours
๐ Logic
Custom Encryption and Decryption System
1. Introduction
This report presents an analysis of a custom encryption and decryption system implemented in Python. The system utilizes a combination of substitution ciphers, base64 encoding, and character shifting to secure text data. The code is designed to handle both ASCII and Korean characters, providing a versatile and culturally relevant encryption solution.
2. Overview of Components
The system is composed of several key components:
Substitution Table Generation and Management:
Generates a random substitution table mapping characters to shuffled counterparts.
Saves and loads the substitution table from a file.
Custom Encryption Algorithm:
Encrypts text by substituting characters, applying a shift based on the number of lines, reversing the text, and finally encoding it with base64.
Custom Decryption Algorithm:
Reverses the encryption process by decoding the base64, reversing the text, and then performing reverse substitution and shifting to recover the original message.
3. Detailed Code Analysis
3.1. Substitution Table Management
3.1.1. generate_substitution_table()
This function generates a substitution table for character substitution. It considers both ASCII printable characters (from space to tilde) and Korean characters (from โ๊ฐโ to โํฃโ).
Steps:
Character Collection: Collects all ASCII printable characters and Korean characters.
Shuffling: Shuffles these characters randomly to create a substitution mapping.
Mapping: Maps each character to a randomly chosen substitute character.
3.1.2. reverse_substitution_table(substitution_table)
This function creates a reverse mapping of the substitution table to facilitate decryption.
Purpose: Ensures that each substituted character can be correctly mapped back to its original form during decryption.
3.1.3. save_substitution_table(substitution_table, filename='substitution_table.pkl') and load_substitution_table(filename='substitution_table.pkl')
These functions handle the saving and loading of the substitution table using the pickle module.
Purpose:
Save Function: Serializes the substitution table and saves it to a file.
Load Function: Deserializes and loads the table from the file if it exists, allowing for persistent storage of the table.
3.2. Custom Encryption Algorithm
3.2.1. calculate_shift(text)
This function determines the shift value used in the encryption process.
Calculation: The shift is calculated based on the number of lines in the text, using the formula
shift = text.count('\n') + 1. This adds an extra level of dynamic shifting based on the structure of the input text.
3.2.2. custom_encrypt(text, substitution_table)
This is the core encryption function.
Process:
Shift Calculation: Determines the shift value from the input text.
Character Substitution and Shifting: For each character in the text:
Applies the shift by adjusting the characterโs Unicode value.
Substitutes the shifted character using the substitution table.
Reversal: Reverses the entire encrypted text to add complexity.
Base64 Encoding: Encodes the reversed text into base64 to ensure safe transmission and storage.
Output: The final encrypted text is a base64-encoded string.
3.3. Custom Decryption Algorithm
3.3.1. custom_decrypt(text, substitution_table)
This function reverses the encryption process to retrieve the original text.
Process:
Base64 Decoding: Decodes the base64-encoded text to retrieve the reversed encrypted string.
Reversal: Reverses the string back to its original order before reversal.
Reverse Substitution and Shifting: For each character:
Applies the reverse substitution using the reverse substitution table.
Adjusts the characterโs Unicode value by reversing the shift.
Output: The final output is the original, decrypted text.
4. Security and Considerations
4.1. Strengths
Multiple Layers of Security: The system combines multiple encryption techniques (substitution, shifting, reversal, base64 encoding), making it more resistant to simple attacks.
Handling of Multilingual Characters: The inclusion of Korean characters makes the encryption scheme culturally relevant and capable of handling diverse data.
4.2. Potential Weaknesses
Predictability of Shifting Mechanism: The shift is based on the number of lines, which could be predictable in some cases, potentially reducing security.
Substitution Table Persistence: If the substitution table is compromised, the entire encryption system could be vulnerable, highlighting the need for secure storage.
4.3. Usage Considerations
Performance: For large texts, the multiple layers of encryption could introduce significant computational overhead.
Scalability: The current system is well-suited for small to medium-sized text blocks, but scalability could be an issue for larger datasets or real-time applications.
5. Conclusion
The custom encryption and decryption system presented here offers a unique and multi-faceted approach to securing text data. While it effectively combines several encryption techniques, ensuring the security of the substitution table and considering potential optimizations for larger datasets would be essential for its broader application. This system is particularly useful for applications requiring the encryption of texts containing both ASCII and Korean characters, making it versatile in a globalized context.
๐ Update
substitution table backup
admin์ฉ json ํ์ผ backup ๋ฐ restore ๊ธฐ๋ฅ ์ถ๊ฐ
encoding update
์ํธํ ํค ๊ด๋ฆฌ: ๋์ฒด ํ ์ด๋ธ์ ํ์ผ์ ์ ์ฅํ๋ ๋์ , ์ํธํ๋ ํค๋ฅผ ์ฌ์ฉํ์ฌ ๋ณด๋ค ์์ ํ๊ฒ ๋์ฒด ํ ์ด๋ธ์ ๊ด๋ฆฌํฉ๋๋ค.
์ํํธ ๊ฐ ๋ณดํธ: ์ํํธ ๊ฐ์ ์ํธํํ๊ฑฐ๋ ๋ณต์กํ๊ฒ ๊ณ์ฐํ์ฌ ์์ธก ๊ฐ๋ฅ์ฑ์ ์ค์ ๋๋ค.
์ ๋ ฅ ๊ฒ์ฆ: ์ ๋ ฅ ํ ์คํธ๋ฅผ ๊ฒ์ฆํ์ฌ ์ ์์ ์ธ ์ฝ๋ ์ฃผ์ ์ ๋ฐฉ์งํฉ๋๋ค.
๋ก๊ทธ ๋ฐ ๋ชจ๋ํฐ๋ง: ๋ก๊ทธ๋ฅผ ์ถ๊ฐํ์ฌ ์ํธํ ๋ฐ ๋ณตํธํ ์์ ์ ๊ธฐ๋กํฉ๋๋ค.
LargeBinary with pickle
Challenge
Retrospective
Last updated