org.polyglotted.crypto.api
Class AbstractCrypto

java.lang.Object
  extended by org.polyglotted.crypto.api.AbstractCrypto
All Implemented Interfaces:
Crypto
Direct Known Subclasses:
AesDecrypter, AesEncrypter, RsaDecrypter, RsaEncrypter

public abstract class AbstractCrypto
extends Object
implements Crypto


Nested Class Summary
static class AbstractCrypto.Mode
           
 
Field Summary
protected  Cipher cipher
           
 
Fields inherited from interface org.polyglotted.crypto.api.Crypto
AES_ALGORITHM, RSA_ALGORITHM
 
Constructor Summary
AbstractCrypto(Cipher cipher)
           
 
Method Summary
 byte[] crypt(byte[] cipherText)
          crypt the given text
protected  byte[] encrypt(String text)
          encrypt the given text
 String getAlgorithm()
           
 Cipher getCipher()
           
protected  String getHeaderLine()
           
abstract  AbstractCrypto.Mode getMode()
           
 boolean handlePropertyFirstLine(String firstLine, PrintWriter writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.polyglotted.crypto.api.Crypto
crypt
 

Field Detail

cipher

protected final Cipher cipher
Constructor Detail

AbstractCrypto

public AbstractCrypto(Cipher cipher)
Method Detail

getCipher

public Cipher getCipher()
Specified by:
getCipher in interface Crypto
Returns:
the cipher that is used by this crypto

getAlgorithm

public String getAlgorithm()
Specified by:
getAlgorithm in interface Crypto
Returns:
the algorithm that is used by this crypto

handlePropertyFirstLine

public boolean handlePropertyFirstLine(String firstLine,
                                       PrintWriter writer)

getHeaderLine

protected String getHeaderLine()

encrypt

protected byte[] encrypt(String text)
encrypt the given text

Parameters:
text - the String representing plain text
Returns:
byte[] representing cipher value

crypt

public final byte[] crypt(byte[] cipherText)
crypt the given text

Specified by:
crypt in interface Crypto
Parameters:
cipherText - the byte[] cipher value
Returns:
byte[] representing plain text

getMode

public abstract AbstractCrypto.Mode getMode()
Returns:
if this crypto performs an encrypt or decrypt operation


Copyright © 2012-2013 Polyglotted Org. All Rights Reserved.