Giter VIP home page Giter VIP logo

fortune-teller's Introduction

fortune-teller

Java Fortuna PRNG clean room implementation. This implementation is JCA compatible. This allow to use Fortuna as secure random number generator for all Java applications.

Usage

Add Maven dependency

<dependency>
    <groupId>dev.prokop.crypto</groupId>
    <artifactId>fortune-teller</artifactId>
    <version>1.0.1</version>
</dependency>

Register JCA provider.

Security.addProvider(new FortunaJcaProvider());

Request SecureRandom instance and generate some random numbers.

final SecureRandom fortuna = SecureRandom.getInstance("Fortuna");

fortuna.generateSeed(22); // generates 22 random bytes

final byte[] bytes = new byte[1024];
fortuna.nextBytes(bytes); // fills byte array with 1 KiB of random data

That's it.

Test it on your system

Don't trust what you read here, please test it on your system before use. Your mileage can vary. You have been warned.

$ wget https://repo1.maven.org/maven2/dev/prokop/crypto/fortune-teller/1.0.1/fortune-teller-1.0.1.jar

$ java -cp fortune-teller-1.0.1.jar dev.prokop.crypto.fortuna.DieHarder | dieharder -g200 -a

#=============================================================================#
#            dieharder version 3.31.1 Copyright 2003 Robert G. Brown          #
#=============================================================================#
   rng_name    |rands/second|   Seed   |
stdin_input_raw|  4.12e+06  |3855428203|
#=============================================================================#
        test_name   |ntup| tsamples |psamples|  p-value |Assessment
#=============================================================================#
   diehard_birthdays|   0|       100|     100|0.92706545|  PASSED
      diehard_operm5|   0|   1000000|     100|0.89760746|  PASSED
  diehard_rank_32x32|   0|     40000|     100|0.28649369|  PASSED
    diehard_rank_6x8|   0|    100000|     100|0.83184980|  PASSED
   diehard_bitstream|   0|   2097152|     100|0.67206395|  PASSED
        diehard_opso|   0|   2097152|     100|0.58135346|  PASSED
...

Try to generate some images:

java -cp fortune-teller-1.0.1.jar dev.prokop.crypto.fortuna.DieHarder | rawtoppm -rgb 256 256 > pixmap
cat pixmap | pnmtopng > random$(date +%Y%m%d%H%M%S).png

Pretty dull, ha!

fortune-teller's People

Contributors

bartprokop avatar edwinprokop avatar natanprokop avatar

Stargazers

 avatar

Watchers

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