org.clazzes.util.sec
Class Crypter

java.lang.Object
  extended by org.clazzes.util.sec.Crypter

public class Crypter
extends java.lang.Object

The Crypter class provides crypt function and some useful random stuff.

Author:
Christoph Lechleitner/IBCL Based upon Crypt by Michael Glad (glad@daimi.aau.dk), Pawel Veselov (vps@phoenix.math.spbu.ru)

Constructor Summary
Crypter()
           
 
Method Summary
static java.lang.String crypt(byte[] salt, byte[] original)
          crypt function.
static java.lang.String crypt(byte[] salt, java.lang.String original)
          crypt function
static java.lang.String crypt(java.lang.String salt, java.lang.String original)
          crypt function.
static java.lang.String getRandomPassword()
          Creates a random password with 8 characters.
static java.lang.String getRandomPassword(int length)
          Creates a random password with a certain number of characters.
static java.lang.String getRandomSalt()
          Creates a random salt String.
static void initDes()
          Initialze unit - may be invoked directly by user.
static boolean selfTest(boolean show)
          This method test crypt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Crypter

public Crypter()
Method Detail

selfTest

public static boolean selfTest(boolean show)
This method test crypt.

Parameters:
show - if it is true, print test results to err stream
Returns:
true, if test succeeded, false if failed.

crypt

public static java.lang.String crypt(byte[] salt,
                                     byte[] original)
crypt function.

Parameters:
salt - two byte array with salt.
original - array, maximum 8 bytes, string to encrypt

crypt

public static java.lang.String crypt(java.lang.String salt,
                                     java.lang.String original)
crypt function.

Parameters:
salt - String, maximum length is 2 with salt.
original - String, maximum 8 bytes, string to encrypt

crypt

public static java.lang.String crypt(byte[] salt,
                                     java.lang.String original)
crypt function

Parameters:
salt - Two bytes array with salt
original - String, maximum 8 characters, string to encrypt

initDes

public static void initDes()
Initialze unit - may be invoked directly by user. Anyway it is invoked automatically from crypt()


getRandomPassword

public static java.lang.String getRandomPassword()
Creates a random password with 8 characters.

Returns:
A random password with 8 characters.

getRandomPassword

public static java.lang.String getRandomPassword(int length)
Creates a random password with a certain number of characters.

Parameters:
length - Length of the password to generate.
Returns:
A random password with length characters.

getRandomSalt

public static java.lang.String getRandomSalt()
Creates a random salt String.

Returns:
A random salt String.


Copyright © 2009. All Rights Reserved.