Diffie-Hellman based secret secure exchange.
Project description
🔐 DH-secrets
Diffie-Hellman based secure secret exchange with CLI interface
A Python package that implements secure secret sharing using the Diffie-Hellman key exchange protocol. Perfect for securely exchanging sensitive information between parties without requiring a pre-shared secret.
✨ Features
- 🔐 Secure Key Exchange: Uses Diffie-Hellman protocol for secure communication
- 🖥️ CLI Interface: Easy-to-use command-line tool (
dhs-cli) - 🔑 Key Management: Generate, list, and manage public/private key pairs
- 📝 Message Encoding/Decoding: Encrypt and decrypt messages between parties
- 🎯 No Pre-shared Secrets: Secure communication without prior key exchange
🚀 Installation
Install lib and cli using the following command.
$ pip install dhsecrets
📖 Usage
The package installs a command-line utility called dhs-cli for easy interaction.
🆘 Help
$ dhs-cli -h
usage: dhs-cli [-h] [-p PATH] {list,generate,encode,decode} ...
Diffie-Hellman secrets.
positional arguments:
{list,generate,encode,decode}
optional arguments:
-h, --help show this help message and exit
-p PATH, --path PATH Key path
🚀 Quick Start
- Generate key pairs for Alice and Bob
- Exchange public keys between parties
- Encode messages using your private key and recipient's public key
- Decode messages using your private key and sender's public key
🔑 Create Keys
We are Alice and we want to share a secret with Bob. First step is to create a key pair and share the public key with Bob.
$ dhs-cli generate priv -n alice
Created alice-3cf5.pub and alice-3cf5.priv
Bob on his side do the following.
$ dhs-cli generate priv -n bob
Created bob-d740.pub and bob-d740.priv.
📋 List Keys
After Alice copies Bob's public key to the key folder, she can list the known keys.
$ dhs-cli list priv
[
{
"file": "./alice-3cf5.priv",
"name": "alice",
"pub": "0319c6697fb8e0d65f0f4d4e93a7fe52ce41e51dfb340a8a2207830158f85e3cf5",
"encodig": "HEX",
"timestamp": "Thursday, 08 September 2022 10:43AM"
}
]
Alice known only 1 private key and 2 publik keys, she can check using the following command.
$ dhs-cli list pub
[
{
"file": "./bob-d740.pub",
"name": "bob",
"pub": "031bf3ecc3458bec4f34f8d47d2db8d46d7679562e3efa5d71edd10d8f35ccd740",
"encodig": "HEX",
"timestamp": "Thursday, 08 September 2022 10:43AM"
},
{
"file": "./alice-3cf5.pub",
"name": "alice",
"pub": "0319c6697fb8e0d65f0f4d4e93a7fe52ce41e51dfb340a8a2207830158f85e3cf5",
"encodig": "HEX",
"timestamp": "Thursday, 08 September 2022 10:43AM"
}
]
🔐 Encode Messages
Alice can encode the string message using the encode command.
$ dhs-cli encode --priv alice-3cf5.priv --pub bob-d740.pub -P "supersecret"
Created alice-bob-d60c.enc
$ cat alice-bob-d60c.enc
E7irYBYdMxBOZGtu221RZSJc3VSQ8yAVt33NmH2eW959Y6lYyMJoCTAG7Q3kxHLBhbIhGYUPLzraUDwvZeHyaDLQHqnq/7K2XNMvtGOy7wWVtlRuYIBGdNXNslGvugke/kr71xkWEfjgG7sUDYyYXJqxUa2Ol24KPoxPDr+5jJYrzSCzGgRZYhEo/2/rsrANBHN5Z698w/bVB4eC8+KyzIJ51A2HaDz0CCHi73bCsJv6sJPLf6U2HYHdK/xig1XADQYb7eWAVv4C51mTi1iv9LqGKoLgMnUD7GEzXVgbCmhol9CG3ZnsDrrLZy/ntEOj9Q+qMhPdhPzKCoxmJkQf+6xLLRSEmkTi7fg4XlKIoERh4IgJ+blZ3MOngmHz/cJs97WlKnTlK4djr3EHdA2N0WO+YVvJ/lXpXCe1dE1RIJrUc04oJtasXMjlZIB8wDXYIBKzAbR8+khgw9/Oapm/BZBBmHpM36yIGgz0zmmnCybYJOagXT93LkatOWK/olqc
🔓 Decode Messages
Bob can decode the message using the decode command.
$ dhs-cli decode --priv bob-d740.priv --pub alice-3cf5.pub -F alice-bob-d60c.enc | jq
{
"from": "0319c6697fb8e0d65f0f4d4e93a7fe52ce41e51dfb340a8a2207830158f85e3cf5",
"to": "031bf3ecc3458bec4f34f8d47d2db8d46d7679562e3efa5d71edd10d8f35ccd740",
"type": "string",
"payload": "supersecret",
"payload_signature": "maYEEc7yhP/iP/8ZtoiuomVtLtXp2FHfrJz0IZvCpR5NDOUpCpBG4WbU3LWGk6Lf0e/ORhNFBXFhXCXyzUw84w==",
"local_timestamp": "Thursday, 08 September 2022 01:23PM"
}
📚 Use Cases
- 💬 Secure messaging: Exchange sensitive information between parties
- 🔐 API key sharing: Securely share API keys and credentials
- 📋 Configuration secrets: Exchange configuration files with sensitive data
- 🎯 One-time secrets: Share temporary passwords or access codes
- 🔒 Document encryption: Encrypt documents for specific recipients
🤝 Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dhsecrets-0.0.3.tar.gz.
File metadata
- Download URL: dhsecrets-0.0.3.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6500182646480fbc384033602cc19f9a701fbb7e2be3758b4820ddd8013ef1eb
|
|
| MD5 |
31d199292bb10725ba77a2db32720212
|
|
| BLAKE2b-256 |
3ef964a6affc559995c5c673d6847e2c2e00242218f0d17a00fc2fe373f7df1d
|
File details
Details for the file dhsecrets-0.0.3-py3-none-any.whl.
File metadata
- Download URL: dhsecrets-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0e5f747954ac6a629d71cbff659d14ca41f14d8325fb077271d8196e3b92cda
|
|
| MD5 |
dbd21332fb20bccc565215262f84d221
|
|
| BLAKE2b-256 |
68711e1eecea98d51e787a53abd2bee2dea072e9fb841790adcd928ffb3c4b04
|