├── mypass ├── __init__.py ├── __pycache__ │ ├── getpass.cpython-310.pyc │ ├── getpass.cpython-312.pyc │ ├── __init__.cpython-310.pyc │ ├── __init__.cpython-312.pyc │ └── encryption_service.cpython-310.pyc ├── server.py ├── getpass.py ├── encryption_service.py └── client.py ├── requirements.txt ├── local_use.py ├── example.py ├── README.md └── visulization.html /mypass/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | requests 3 | cryptography -------------------------------------------------------------------------------- /mypass/__pycache__/getpass.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JL-ghcoder/mypass/HEAD/mypass/__pycache__/getpass.cpython-310.pyc -------------------------------------------------------------------------------- /mypass/__pycache__/getpass.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JL-ghcoder/mypass/HEAD/mypass/__pycache__/getpass.cpython-312.pyc -------------------------------------------------------------------------------- /mypass/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JL-ghcoder/mypass/HEAD/mypass/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /mypass/__pycache__/__init__.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JL-ghcoder/mypass/HEAD/mypass/__pycache__/__init__.cpython-312.pyc -------------------------------------------------------------------------------- /mypass/__pycache__/encryption_service.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JL-ghcoder/mypass/HEAD/mypass/__pycache__/encryption_service.cpython-310.pyc -------------------------------------------------------------------------------- /local_use.py: -------------------------------------------------------------------------------- 1 | from mypass.getpass import get_password 2 | 3 | password3 = get_password( 4 | encrypted_data="", 5 | iv="", 6 | local_key="" 7 | ) 8 | 9 | print("password3: ", password3) -------------------------------------------------------------------------------- /example.py: -------------------------------------------------------------------------------- 1 | from mypass.getpass import get_password 2 | 3 | password1 = get_password( 4 | server_url="http://localhost:6666/decrypt", 5 | key_file="encrypted_key.json" 6 | ) 7 | 8 | password2 = get_password( 9 | server_url="http://localhost:6666/decrypt", 10 | encrypted_data="xxx", 11 | iv="xxx" 12 | ) 13 | 14 | password3 = get_password( 15 | encrypted_data="xxx", 16 | iv="xxx", 17 | local_key="xxx" 18 | ) 19 | 20 | print("password1: ", password1) 21 | print("password2: ", password2) 22 | print("password3: ", password3) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MyPass - 加密密码管理系统 2 | 3 | 一个终端界面的加密密码管理系统,用于安全地存储和获取敏感信息,如数据库密码、API密钥等。该系统使用AES-256-CBC加密算法,通过客户端-服务器架构提供安全的密码解密服务。 4 | 5 | 我的用法: 6 | 1. 运行encryption_service.py,设置一个解密密钥,将密码进行加密 7 | 2. 在一台服务器运行server.py,用于提供远程解密服务,并且输入正确的解密密钥进行解密 8 | 3. 在交易服务器上通过 mypass.getpass 来访问远端服务将加密的密码解密 9 | 4. 关闭 server.py 10 | 11 | 这样做可以确保全程不出现密码的明文,并且即使哪一台被黑也不会泄露出密码。 12 | 13 | 关闭解密服务后黑客只可能通过内存探针获取密码,但这基本上是不可能实现的。 14 | 15 | 即使两台服务器都被黑客同时黑掉,黑客也无法获取明文密码,并且只要解密密钥没有泄露,解密服务也无法完成解密工作。 16 | 17 | **我的建议:** 18 | 将解密用的server.py直接跑在本地而不是公网服务器,绑定cloudflare的tunnel,要进行密码验证的时候在本地运行服务并且让cloudflare广播并且接听,这样cloudflare tunnel会建立一个加密隧道,通信会在TLS层面加密,中间人攻击的风险会大幅降低。 19 | 20 | ## 安装 21 | 22 | ### 依赖项 23 | 24 | ```bash 25 | pip install flask requests cryptography 26 | ``` 27 | 28 | ## 使用方法 29 | 30 | ### 1. 加密数据 31 | 32 | 首先使用加密服务加密您的敏感数据: 33 | 34 | ```bash 35 | python encryption_service.py 36 | ``` 37 | 38 | 按照界面提示输入您的数据和加密密钥,加密结果将保存到`encrypted_key.json`文件。 39 | 40 | ### 2. 启动解密服务器 41 | 42 | 在需要提供解密服务的机器上运行: 43 | 44 | ```bash 45 | python server.py 46 | ``` 47 | 48 | 输入端口号和解密密钥(必须与加密时使用的密钥相同)。 49 | 50 | ### 3. 使用客户端解密 51 | 52 | 要手动解密数据,可以运行客户端: 53 | 54 | ```bash 55 | python client.py 56 | ``` 57 | 58 | 根据提示输入服务器URL和加密数据。 59 | 60 | ### 4. 在应用程序中使用 61 | 62 | ```python 63 | from mypass.getpass import get_password 64 | 65 | password1 = get_password( 66 | server_url="http://localhost:6666/decrypt", 67 | key_file="encrypted_key.json" 68 | ) 69 | 70 | password2 = get_password( 71 | server_url="http://localhost:6666/decrypt", 72 | encrypted_data="6BxemLxyiBXFwfMEetiXiQ==", 73 | iv="6WhgnvA+zrAEiySRSpSH6w==" 74 | ) 75 | 76 | password3 = get_password( 77 | encrypted_data="6BxemLxyiBXFwfMEetiXiQ==", 78 | iv="6WhgnvA+zrAEiySRSpSH6w==", 79 | local_key="helloworld" 80 | ) 81 | 82 | print("password1: ", password1) 83 | print("password2: ", password2) 84 | print("password3: ", password3) 85 | ``` -------------------------------------------------------------------------------- /mypass/server.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import json 4 | import logging 5 | import threading 6 | import time 7 | from flask import Flask, request, jsonify 8 | from encryption_service import decrypt 9 | 10 | logging.basicConfig( 11 | level=logging.INFO, 12 | format='%(asctime)s - %(levelname)s - %(message)s', 13 | handlers=[ 14 | logging.StreamHandler(sys.stdout) 15 | ] 16 | ) 17 | logger = logging.getLogger(__name__) 18 | 19 | def clear_screen(): 20 | os.system('cls' if os.name == 'nt' else 'clear') 21 | 22 | def print_banner(): 23 | banner = """ 24 | ) ( ) ( ( ) ( ( 25 | ( )\ ) ` ) ( /( ( ( ___ ( ))\ )( /(( ))\ )( 26 | )\ '(()/( /(/( )(_)) )\ )\|___|)\ /((_)(()\ (_))\ /((_)(()\ 27 | _((_)) )(_))((_)_\ ((_)_ ((_)((_) ((_)(_)) ((_)_)((_)(_)) ((_) 28 | | ' \()| || || '_ \)/ _` |(_-<(_-< (_- 2 | 3 | 4 | 5 | 6 | 加密解密工具 7 | 8 | 9 | 10 |
11 |

加密解密工具

12 |
 13 |  __  __  _  _  ____   __    ___  ___      ____  _____  _____  __   
 14 | (  \/  )( \/ )(  _ \ /__\  / __)/ __) ___(_  _)(  _  )(  _  )(  )  
 15 |  )    (  \  /  )___//(__)\ \__ \\__ \(___) )(   )(_)(  )(_)(  )(__ 
 16 | (_/\/\_) (__) (__) (__)(__)(___/(___/     (__) (_____)(_____)(____)
 17 |         
18 |
19 | 20 |
21 |

操作选择

22 |
23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
32 |
33 |

加密数据

34 |
35 |
36 | 37 |
38 |
39 |
40 | 41 |
42 | 43 |
44 | 45 | 61 |
62 | 63 | 64 | 90 |
91 | 92 | 243 | 244 | --------------------------------------------------------------------------------