com.dalsemi.system
Class Security

java.lang.Object
  |
  +--com.dalsemi.system.Security

public class Security
extends java.lang.Object

A SHA-1 Hash and a "Better than Java" random number generator.


Method Summary
static int getRandom()
          Return a 32 bit random number from the system random number generator.
static byte[] hashMessage(byte[] message)
          Computes a SHA-1 hash on the given message.
static void hashMessage(byte[] msg, int msgoffs, int msglen, byte[] hash, int hashoffs, byte[] buffer)
          Computes a SHA-1 hash on the given message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRandom

public static int getRandom()
Return a 32 bit random number from the system random number generator. This value is constructed from four calls into the system generator each which returns a byte. Each byte is the LSB of a 16 bit LFSR which is mixed using XOR with clock/timer values from throughout the sytem. This is definitely not cryptographically secure, but it's better than pure pseudo random.
Returns:
one 32 bit pseudorandom doubleplusgood number

hashMessage

public static byte[] hashMessage(byte[] message)
Computes a SHA-1 hash on the given message.
See FIPS 180-1 for more information on SHA-1.
Parameters:
message - the message to hash
Returns:
the result of the hash (20 bytes)

hashMessage

public static void hashMessage(byte[] msg,
                               int msgoffs,
                               int msglen,
                               byte[] hash,
                               int hashoffs,
                               byte[] buffer)
Computes a SHA-1 hash on the given message.
See FIPS 180-1 for more information on SHA-1.
Parameters:
msg - the message to hash
msgoffs - offset into the message array
msglen - length of the message to hash
hash - holds the hash value on return (20 bytes minimum)
hashoffs - offset into the hash value array
buffer - buffer for SHA-1 calculation (320 bytes minimum)


Also see:
o TINI 1.16 API, Optional Modules
o TINI Home Page
o 1-Wire API

o JDK 1.1

Last update Wed Jun 8 17:19:36 CDT 2005