Giter Site home page Giter Site logo

hapi-iron-oxide's Introduction

hapi-iron-oxide

This module is made to be compatible with brc-dd/iron-webcrypto, which is the crate that backs vvo/iron-session. This allows APIs made in Rust be able to talk to Next.js.

Installation

cargo add hapi-iron-oxide

Usage

Salt size can be customized from both const generics. The first generic argument is the salt size of the encryption algorithm (AES-256, AES-128). And the second generic argument is the salt size of integrity algorithm (SHA-256).

use hapi_iron_oxide::*;

let password = "passwordpasswordpasswordpasswordpasswordpasswordpasswordpassword";
let data = "Hello World Please";

let sealed = seal::<32, 32, _>(data.to_string(), password, Default::default());
let unsealed = unseal(sealed, password.clone(), Default::default());

assert_eq!(unsealed.unwrap(), data.to_string());

The options struct can be customized like This

use hapi_iron_oxide::*;

let password = "passwordpasswordpasswordpasswordpasswordpasswordpasswordpassword";
let data = "Hello World Please";

let options = SealOptionsBuilder::new().ttl(1000);

let sealed = seal::<32, 32, _>(data.to_string(), password, options);

assert_eq!(
    options,
    SealOptions {
        encryption: EncryptionOptions {
            algorithm: Algorithm::Aes256Cbc,
            iterations: 1,
            minimum_password_length: 32,
        },
        integrity: EncryptionOptions {
            algorithm: Algorithm::Sha256,
            iterations: 1,
            minimum_password_length: 32,
        },
        ttl: 1000,
        timestamp_skew: 60,
        local_offset: 0,
    }
);
assert!(!sealed.is_empty());

Thank you

Thank you to

hapi-iron-oxide's People

Contributors

grindarius avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.