com.dalsemi.system
Class Security
java.lang.Object
|
+--com.dalsemi.system.Security
- public class Security
- extends 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[] MsgStr)
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 |
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[] MsgStr)
- 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)