org.polyglotted.crypto.asymmetric
Class RsaEncrypter

java.lang.Object
  extended by org.polyglotted.crypto.api.AbstractCrypto
      extended by org.polyglotted.crypto.asymmetric.RsaEncrypter
All Implemented Interfaces:
Crypto

public class RsaEncrypter
extends AbstractCrypto

RsaEncrypter uses RSA algorithm of Asymmetric key cryptography to convert plain text into unreadable cipher text.

Author:
Shankar Vasudevan

Nested Class Summary
 
Nested classes/interfaces inherited from class org.polyglotted.crypto.api.AbstractCrypto
AbstractCrypto.Mode
 
Field Summary
 
Fields inherited from class org.polyglotted.crypto.api.AbstractCrypto
cipher
 
Fields inherited from interface org.polyglotted.crypto.api.Crypto
AES_ALGORITHM, RSA_ALGORITHM
 
Constructor Summary
RsaEncrypter(PublicKey key)
          Create a new RsaEncrypter
 
Method Summary
 String crypt(String text)
          Perform encrypt or decrypt action
static String encrypt(InputStream pubKeyIs, String input)
          Encrypt the given text with a public key
static void encryptFile(InputStream pubKeyIs, InputStream input, OutputStream output)
          Encrypt the incoming property file and copy the resulting data into the output stream.
static void encryptPropertyFile(InputStream pubKeyIs, InputStream propertyIs, OutputStream output, String prefix)
          Encrypt the incoming property file and copy the resulting data into the output stream.
 AbstractCrypto.Mode getMode()
           
 void setBase64Options(int options)
           
 
Methods inherited from class org.polyglotted.crypto.api.AbstractCrypto
crypt, encrypt, getAlgorithm, getCipher, getHeaderLine, handlePropertyFirstLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RsaEncrypter

public RsaEncrypter(PublicKey key)
Create a new RsaEncrypter

Parameters:
key - the PublicKey for the encryption
Method Detail

getMode

public AbstractCrypto.Mode getMode()
Specified by:
getMode in class AbstractCrypto
Returns:
if this crypto performs an encrypt or decrypt operation

crypt

public String crypt(String text)
Description copied from interface: Crypto
Perform encrypt or decrypt action

Parameters:
text - the String to crypt
Returns:
the result String

setBase64Options

public void setBase64Options(int options)
Parameters:
options - the Base64Options for encoding

encrypt

public static String encrypt(InputStream pubKeyIs,
                             String input)
Encrypt the given text with a public key

Parameters:
pubKeyIs - the public key input stream
input - the input data
Returns:
the encrypted cipher value

encryptFile

public static void encryptFile(InputStream pubKeyIs,
                               InputStream input,
                               OutputStream output)
Encrypt the incoming property file and copy the resulting data into the output stream.

Parameters:
pubKeyIs - the public key input stream
input - the file input stream
output - the output stream to write the encrypted values

encryptPropertyFile

public static void encryptPropertyFile(InputStream pubKeyIs,
                                       InputStream propertyIs,
                                       OutputStream output,
                                       String prefix)
Encrypt the incoming property file and copy the resulting data into the output stream.

Parameters:
pubKeyIs - the public key input stream
propertyIs - the property file input stream
output - the output stream to write the encrypted values
prefix - the String prefix for lines which have to be encrypted


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