Crate cargo_pwhide
source ·Expand description
cargo-pwhide provides tooling to hide passwords
This doesn’t provide any security
It consists of a cargo subcommand to encrypt passwords and a simple macro for decrypting
Encryption
install the cargo subcommand with:
cargo install cargo-pwhide
Then go to the root of your project where the Cargo.toml is
and encrypt a password
cargo pwhide encrypt MySecretPassword
This will deliver an encrypted data for example:
QDc2rswTJRHrFEgT2Ech77xuScNGfGGKFIJq6MJcI1lKg1hfaowsg5
Use this in configuration files on in the command code
Decryption in the program
Add to your Config.toml
cargo-pwhide = {version="*", feature=["lib"], default-features = false}**
This reduces the number of dependencies and is great for compile time :)
For decryption just use the provided macro
use cargo_pwhide::pwdecrypt;
let cleartext:Result<String,anyhow::Error>=pwdecrypt!("QDc2rswTJRHrFEgT2Ech77xuScNGfGGKFIJq6MJcI1lKg1hfaowsg5");
and automatically decrpytion is done
how does it work?
The tool is using the package name as secret The password is encrypted using ChaCha20Poly1305 and a random nounce
This doesn’t provide any security but is better compared to storing plain text passwords in version control
Macros
- The macro is used for easy decrpytion of password
Functions
- This is used to decrpyt the password encrypted with subcommand tools cargo pwhide encrypt
- This is used to encrpyt a password function used by subcommand tools cargo pwhide encrypt