lua-arc4random

Cryptographically secure PRNG for Lua
Log | Files | Refs | README

test.lua (331B)


      1 #! /usr/bin/lua
      2 
      3 local arc4 = require( "arc4random" )
      4 
      5 for i = 1, 100 do
      6 	print( ( "%.3f" ):format( arc4.random() ) )
      7 end
      8 print( arc4.random() )
      9 print( arc4.random( 3 ) )
     10 print( arc4.random( -5, 5 ) )
     11 
     12 local str = arc4.buf( 16 )
     13 str = str:gsub( "(.)", function( c )
     14 	return ( "%02x" ):format( string.byte( c ) )
     15 end )
     16 print( str )