2 releases
0.4.1 | Oct 31, 2019 |
---|---|
0.4.0 | Oct 6, 2019 |
#2413 in Cryptography
Used in schemeguardian
17KB
230 lines
RedactedSecret
Secret
wrapper type for more carefully handling secret values (e.g. passwords, cryptographic keys, access tokens or other credentials).
Usage
use redactedsecret::{Secret, SecretString, SecretVec, SecretBox};
Examples
- Create a
Secret
on any type (Generic Type)
use redactedsecret::{Secret, ExposeSecret};
let dummy_PIN = Secret::new(1234);
assert_eq!(dummy_PIN.expose_secret().to_owned(), 1234);
- Create a string from
SecretString
use redactedsecret::{SecretString, ExposeSecret};
let dummy_PIN = SecretString::new("I am a string PIN".to_owned());
assert_eq!(dummy_PIN.expose_secret().to_owned(), "I am a string PIN".to_owned());
- Create a Boxed type from a
SecretBox
type
use redactedsecret::{Secret, ExposeSecret};
let dummy_PIN = Box::new(Secret::new(1234));
assert_eq!(dummy_PIN.expose_secret().to_owned(), 1234);
- Create a vector from a
SecretVec
use redactedsecret::{SecretVec, ExposeSecret};
let dummy_PIN = SecretVec::new(vec![1234]);
assert_eq!(dummy_PIN.expose_secret().to_owned(), vec![1234]);
Dependencies
~29–275KB