Class KarnPrintWriter

java.lang.Object
  java.io.Writer
      java.io.PrintWriter
          KarnPrintWriter

public class KarnPrintWriter
extends java.io.PrintWriter


Field Summary
private  java.security.MessageDigest md
          MessageDigest common to multiple functions in class, implements SHA-1
private  java.security.SecureRandom r
          SecureRandom to pad the shorter blocks with random data, and not just all zeros
private  java.math.BigInteger sharedSecret
          Stores the shared key for the encrypted session
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
KarnPrintWriter(java.io.Writer out, java.math.BigInteger sharedKey)
          Initialize the PrintWriter with a specific OutputStream and shared encryption key, but set autoFlush to false
KarnPrintWriter(java.io.Writer out, boolean autoFlush, java.math.BigInteger sharedKey)
          Initialize a new PrintWriter with the specified OutputStream, autoFlush on/off and a designated shared key
 
Method Summary
 java.lang.String encrypt(java.lang.String msg)
          General encryption function called by all print functions
 void println(java.lang.String msg)
          Print a complete encrpyted line (record)
 
Methods inherited from class java.io.PrintWriter
checkError, close, flush, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sharedSecret

private java.math.BigInteger sharedSecret
Stores the shared key for the encrypted session


md

private java.security.MessageDigest md
MessageDigest common to multiple functions in class, implements SHA-1


r

private java.security.SecureRandom r
SecureRandom to pad the shorter blocks with random data, and not just all zeros

Constructor Detail

KarnPrintWriter

public KarnPrintWriter(java.io.Writer out,
                       boolean autoFlush,
                       java.math.BigInteger sharedKey)
                throws java.security.NoSuchAlgorithmException
Initialize a new PrintWriter with the specified OutputStream, autoFlush on/off and a designated shared key


KarnPrintWriter

public KarnPrintWriter(java.io.Writer out,
                       java.math.BigInteger sharedKey)
                throws java.security.NoSuchAlgorithmException
Initialize the PrintWriter with a specific OutputStream and shared encryption key, but set autoFlush to false

Method Detail

encrypt

public java.lang.String encrypt(java.lang.String msg)
General encryption function called by all print functions


println

public void println(java.lang.String msg)
Print a complete encrpyted line (record)