Session.lua: Difference between revisions

From Alpine Linux
No edit summary
 
Line 14: Line 14:
will output a hash from /dev/urandom that is 17 char long
will output a hash from /dev/urandom that is 17 char long


=== hash_ip_address ===
=== hash_ip_addr ===
'''INPUT:'''<BR>
'''INPUT:'''<BR>
This library required the following inputs/parameters.
This library required the following inputs/parameters.
Line 24: Line 24:
  -- Set variable/Call for this library
  -- Set variable/Call for this library
  bobo = require "session"
  bobo = require "session"
  print(bobo.has_ip_address("192.168.10.1))
  print(bobo.hash_ip_addr("192.168.10.1))
Output could be:
Output could be:
  c0a80a01
  c0a80a01

Revision as of 17:16, 8 July 2008

random_hash

Returns a base64 encoded hash, using _- as the extra characters, as these are safe for using in a URL.

INPUT:
hash size, in bits OUTPUT:
A base64 encoded hash of at least bits length.

  • HASH
    • Comes from reading /dev/urandom

CODING EXAMPLE:

-- Set variable/Call for this library
bobo = require "session"
print(bobo.random_hash(100))

will output a hash from /dev/urandom that is 17 char long

hash_ip_addr

INPUT:
This library required the following inputs/parameters.

  • ip address

OUTPUT:
This library deliverers the following output/parameters.

  • HEX incoded ip address

CODING EXAMPLE:

-- Set variable/Call for this library
bobo = require "session"
print(bobo.hash_ip_addr("192.168.10.1))

Output could be:

c0a80a01

ip_addr_from_hash

INPUT:
This library required the following inputs/parameters.

  • HEX encoded ip address

OUTPUT:
This library deliverers the following output/parameters.

  • ip address

CODING EXAMPLE:

-- Set variable/Call for this library
bobo = require "session"
print(bobo.ip_addr_from_hash("c0a80a01")

Output could be:

192.168.10.1

serialize

INPUT:
This library required the following inputs/parameters.

  • name
    • What to use for the new elements
  • value
    • value: table to serialize
  • saved
    • not sure what its used of

OUTPUT:
This library deliverers the following output/parameters.

  • string with the table serialized

CODING EXAMPLE:

-- Set variable/Call for this library
bobo = require "session"
t = {foo={1,2,3,4}, "one", "two", "bar", "baz"}
stuff = bobo.serialize(1,t)
print(stuff)
1 = {}
1[1] = "one"
1[2] = "two"
1[3] = "bar"
1[4] = "baz"
1["foo"] = {}
1["foo"][1] = 1
1["foo"][2] = 2
1["foo"][3] = 3
1["foo"][4] = 4

save_session

INPUT:
This library required the following inputs/parameters.

  • sessionpath,session,sessiontable

OUTPUT:
This library deliverers the following output/parameters.

  • true is success, false if error

CODING EXAMPLE:

-- Set variable/Call for this library
bobo = require "session"
print(bobo.save_session("tmp", session, sessiontable)
-- will print true is success
-- false if failed