edu.northwestern.at.utils.crypto
Class Crypto

java.lang.Object
  extended by edu.northwestern.at.utils.crypto.Crypto

public class Crypto
extends java.lang.Object

Cryptography utilities.

This static class is a port of the old Ph encryption code from C to Java.


Method Summary
static java.lang.String crypt(java.lang.String str, java.lang.String salt)
          Encrypts a string using a salt.
static java.lang.String encryptPassword(java.lang.String password)
          Encrypts a password.
static java.lang.String encryptPhChallenge(java.lang.String password, java.lang.String challenge)
          Encrypts the response to a Ph challenge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

crypt

public static java.lang.String crypt(java.lang.String str,
                                     java.lang.String salt)
Encrypts a string using a salt.

This is the BSD "crypt" function ported to Java.

Parameters:
str - The string to encrypt.
salt - The salt string.
Returns:
The encrypted string.

encryptPassword

public static java.lang.String encryptPassword(java.lang.String password)
Encrypts a password.

The password is one-way encrypted by using the BSD "crypt" function to encrypt the password using itself as the salt.

Parameters:
password - The password to be encrypted.
Returns:
The encrypted password.

encryptPhChallenge

public static java.lang.String encryptPhChallenge(java.lang.String password,
                                                  java.lang.String challenge)
Encrypts the response to a Ph challenge.

Parameters:
password - The password entered by the user.
challenge - The challenge sent by the Ph server.
Returns:
The response to send to the Ph server in an "answer" command.