redactedsecret

Crates.ioredactedsecret
lib.rsredactedsecret
version0.4.1
sourcesrc
created_at2019-10-06 10:31:11.311161
updated_at2019-10-31 14:38:39.93466
description This is a fork of the official Secrecy crate [https://github.com/iqlusioninc/crates/] Wrapper types and traits for secret management which help ensure they aren't accidentally copied, logged, or otherwise exposed (as much as possible), and also ensure secrets are securely wiped from memory when dropped.
homepagehttps://github.com/charleschege/RedactedSecret
repositoryhttps://github.com/charleschege/RedactedSecret
max_upload_size
id170349
size27,767
CharlesĀ·Chege (charleschege)

documentation

README

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

  1. 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);
  1. 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());
  1. 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);
  1. 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]);
Commit count: 0

cargo fmt