Giter VIP home page Giter VIP logo

lazyxchacha-rs's Introduction

lazyxchacha-rs

Lazy XChaCha20-Poly1305 in Rust base on RustCrypto: ChaCha20Poly1305.

"Buy Me A Coffee"

Algorithm details

  • Key exchange: X25519
  • Encryption: XChaCha20
  • Authentication: Poly1305

Benchmark

Gnuplot not found, using plotters backend
encrypt                 time:   [1.4821 µs 1.4897 µs 1.5010 µs]
                        change: [-33.403% -32.895% -32.441%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) high mild
  3 (3.00%) high severe

Benchmarking decrypt: Warming up for 3.0000 s
decrypt                 time:   [1.3529 µs 1.3560 µs 1.3594 µs]
                        change: [-27.218% -27.057% -26.897%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  8 (8.00%) high mild

How to use

  • Generate KeyPair
let keypair = KeyPair::new();
  • Key Exchange & Shared Key
let client_kp = KeyPair::new();
let server_kp = KeyPair::new();
let server_pk = server_kp.pk_string();

let shared_key = SharedKey::new(server_pk, client_kp.sk);
  • Encrypt
let lazyxchacha = LazyXChaCha::new();
let shared_key = SharedKey::new(server_pk, client_kp.sk);
let plaintext = r#"{"message": "hi"}"#;

let ciphertext = lazyxchacha.encrypt(plaintext, shared_key);
  • Decrypt
let lazyxchacha = LazyXChaCha::new();
let shared_key = SharedKey::new(server_pk, client_kp.sk);
let ciphertext = "58b99ca4a7";

let plaintext = lazyxchacha.decrypt(ciphertext, shared_key);

lazyxchacha-rs's People

Contributors

prongbang 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.