org.PingOO.DLAI.PPM.codec
Class ToServerCodec

java.lang.Object
  |
  +--org.PingOO.DLAI.PPM.codec.ToServerCodec

public class ToServerCodec
extends java.lang.Object

This class use the server's public key to encrypt messages from the client.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)

Constructor Summary
private ToServerCodec()
          Hides the constructor from the outside.
 
Method Summary
static byte[] encode(byte[] data)
          Encrypts a byte array using the default method.
static byte[] encode(char[] data)
          Encrypts a String using the default method.
static byte[] encode(java.lang.String data)
          Encrypts a String using the default method.
static void setPublicKey(java.lang.String key)
          Sets the public key needed to encode message before they are sent to the server.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

ToServerCodec

private ToServerCodec()
Hides the constructor from the outside.
Method Detail

setPublicKey

public static void setPublicKey(java.lang.String key)
Sets the public key needed to encode message before they are sent to the server.
! This function can only be called one time. Further attemps to reset the key, once it has allready been initialized, will do nothing.
Parameters:
key -  

encode

public static byte[] encode(byte[] data)
                     throws java.lang.NullPointerException
Encrypts a byte array using the default method.
Parameters:
data - The datas to encrypt.
Returns:
An encrypted byte array.
Throws:
java.lang.NullPointerException - If data is null.

encode

public static byte[] encode(java.lang.String data)
                     throws java.lang.NullPointerException
Encrypts a String using the default method.
Parameters:
data - The datas to encrypt.
Returns:
An encrypted byte array.
Throws:
java.lang.NullPointerException - If data is null.

encode

public static byte[] encode(char[] data)
                     throws java.lang.NullPointerException
Encrypts a String using the default method.
Parameters:
data - The datas to encrypt.
Returns:
An encrypted byte array.
Throws:
java.lang.NullPointerException - If data is null.