Git Product home page Git Product logo

rust-rsa's Introduction

Totally for-fun RSA implementation

Pretty please don't use this for anything requiring real security. I am building it to gain an understanding of how RSA works and how attacks on it function, and as such it is almost certainly vulnerable to many of them

This library implements RSA and RSA-related functionality. Currently, you can generate 1024-bit prime numbers, check any bignum::BigUint for primality, encrypt, and decrypt messages with very naive 1024-bit RSA:

extern crate rsa;

fn main() {
  let p = rsa::primes::big_prime(1024);
  println!("'{} is prime' is a {} statement!", p, rsa::primes::is_prime(&p));
  //-> '{Some 1024-bit prime number} is prime' is a true statement!

  let message = ~"Some super secret scary message that I don't want anybody to see!";
  let (public_key, private_key) = rsa::gen_keys_default();
  let encrypted = public_key.encrypt(message);
  println!("The secret message is hidden inside of '{}'", encrypted); //-> A bunch of hex
  let decrypted = private_key.decrypt(encrypted);
  println!("But we can get it out! It is '{}'", decrypted); //-> super secret scary message
}

Installation

To build and test:

make deps && make test

To install into system rustlib:

make install

To build examples:

make examples

Examples can then be run from build/examples. (Note: building examples also installs the library system-wide, which may not be desired.)

rust-rsa's People

Contributors

jsanders avatar

Watchers

James Cloos 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.