Crate data_vault[][src]

Expand description

Data Vault is a modular, pragmatic, credit card vault for Rust.

Example

## Cargo.toml
[dependencies]
data_vault = "^0.2"
## .env OR environment variables
REDIS_URL=redis://:foobared@127.0.0.1/
## REDIS_POOL_MAX_SIZE=16
ENCRYPTED_DATA_VAULT_KEY=000102030405060708090a0b0c0d0e0f
ENCRYPTED_DATA_VAULT_IV=f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
/// example.rs

// traits
use data_vault::DataVault;
use data_vault::encryption::traits::Encryption;

// data vault
use data_vault::RedisDataVault;
use data_vault::PostgresDataVault;
// Interchangeable encryption
use data_vault::encryption::AesGcmSivEncryption;
// Interchangeable tokenizer
use data_vault::tokenizer::Blake3Tokenizer;

// credit card type
use credit_card::CreditCard;

use tokio;

#[tokio::main(flavor = "multi_thread")]
async fn main() {
    let vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();

    let cc = CreditCard {
        number: "4111111111111111".to_string(),
        cardholder_name: "Graydon Hoare".to_string(),
        expiration_month: "01".to_string(),
        expiration_year: "2023".to_string(),
        brand: None,
        security_code: None
    };

    let token = vault.store_credit_card(&cc).await.unwrap();
    let credit_card = vault.retrieve_credit_card(&token.to_string()).await.unwrap();
    assert_eq!(credit_card.number, cc.number)
}

Current Features

  • Store Credit Cards
  • Store String
  • Automatic Encryption and Decryption
  • Blake3 tokenization
  • Redis Server, URL connection configuration
  • Configurable from .env file or Environment Variables
  • Interchangeable Encryption
  • Interchangeable Tokenization hasher

Future Features

  • Postgres Database

Performance

This example output the following performance stats with an AMD Ryzen 9 3900X. Showing the possibility of tokenizing ~100,000 credit cards per second.

tokenized and stored 100000 credit cards in 1.058474365s retrieved 100000 credit cards in 5.353857633s tokenized, stored, and retrieved 100000 credit cards in 6.412331998s

Modules

encryption
tokenizer
utils

Structs

PostgresDataVault

Use postgres as a data vault back end

RedisDataVault

Use redis as a data vault back end

Traits

DataVault

This is what a Data Vault can do It’s fundamental purpose is to store and retrieve data in a secure encrypted manner