lua-symmetric

Symmetric crypto for Lua
Log | Files | Refs

test.lua (475B)


      1 #! /usr/bin/lua
      2 
      3 local symmetric = require( "symmetric" )
      4 
      5 local function tohex( str )
      6 	return ( str:gsub( "(.)", function( c )
      7 		return ( "%02x" ):format( string.byte( c ) )
      8 	end ) )
      9 end
     10 
     11 local key = symmetric.key()
     12 print( tohex( key ) )
     13 
     14 local c = symmetric.encrypt( "hello", key )
     15 print( tohex( c ) )
     16 
     17 print( symmetric.decrypt( c, key ) )
     18 
     19 print( symmetric.decrypt( "1", key ) )
     20 
     21 print( pcall( symmetric.encrypt, nil, key ) )
     22 print( pcall( symmetric.decrypt, nil, key ) )