com.softabar.crypt
Class SoftaCryptHelper

java.lang.Object
  extended bycom.softabar.crypt.SoftaCryptHelper

public class SoftaCryptHelper
extends java.lang.Object

Helper methods for SoftaCrypt. See usage in main(java.lang.String[]).

Version:
1.0 Copyright (C) 2005 softabar.com

Constructor Summary
SoftaCryptHelper()
           
 
Method Summary
static void aesDecrypt(java.lang.String passPhrase, java.io.File inFile, java.io.File outFile)
           
static void aesEncrypt(java.lang.String passPhrase, java.io.File inFile, java.io.File outFile)
           
static void base64Decode(java.io.File inFile, java.io.File outFile)
           
static void base64Encode(java.io.File inFile, java.io.File outFile)
           
static java.lang.String crc32(java.io.File file)
           
static java.lang.String crc32(java.lang.String text)
           
static java.lang.String digest(java.lang.String algorithm, java.io.File file)
           
static java.lang.String digest(java.lang.String algorithm, java.lang.String text)
           
static void main(java.lang.String[] args)
           Usage: java com.softabar.crypt.SoftaCryptHelper <command> <argument1> <argument2> ...
static byte[] makeKey(java.lang.String passPhrase)
           
static void twofishDecrypt(java.lang.String passPhrase, java.io.File inFile, java.io.File outFile)
           
static void twofishEncrypt(java.lang.String passPhrase, java.io.File inFile, java.io.File outFile)
           
static void xteaDecrypt(java.lang.String passPhrase, java.io.File inFile, java.io.File outFile)
           
static void xteaEncrypt(java.lang.String passPhrase, java.io.File inFile, java.io.File outFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftaCryptHelper

public SoftaCryptHelper()
Method Detail

digest

public static java.lang.String digest(java.lang.String algorithm,
                                      java.lang.String text)
Parameters:
algorithm - Digest algorithm (sha1, sha224, sha256, sha384 or sha512)
text - Text to calculate digest
Returns:
String presentation of digest value

digest

public static java.lang.String digest(java.lang.String algorithm,
                                      java.io.File file)
Parameters:
algorithm - Digest algorithm (sha1, sha224, sha256, sha384 or sha512)
file - File to calculate digest
Returns:
String presentation of digest value

crc32

public static java.lang.String crc32(java.lang.String text)
Parameters:
text - Text to calculate CRC32
Returns:
CRC32 as hexadecimal string

crc32

public static java.lang.String crc32(java.io.File file)
Parameters:
file - File to calculate CRC32
Returns:
CRC32 as hexadecimal string

base64Encode

public static void base64Encode(java.io.File inFile,
                                java.io.File outFile)
Parameters:
inFile - File to encode
outFile - Encoded file

base64Decode

public static void base64Decode(java.io.File inFile,
                                java.io.File outFile)
Parameters:
inFile - File to decode
outFile - Decoded file

makeKey

public static byte[] makeKey(java.lang.String passPhrase)
Parameters:
passPhrase - Any string as passphrase
Returns:
16-byte key. Key is generated by calculating SHA-1 of passphrase and returning 16 left most bytes. If exception happened, returns key full of zeros

aesEncrypt

public static void aesEncrypt(java.lang.String passPhrase,
                              java.io.File inFile,
                              java.io.File outFile)
Parameters:
passPhrase - Passphrase for AES encryption
inFile - File to encrypt
outFile - Encrypted file

aesDecrypt

public static void aesDecrypt(java.lang.String passPhrase,
                              java.io.File inFile,
                              java.io.File outFile)
Parameters:
passPhrase - Passphrase for AES decryption
inFile - File to decrypt
outFile - Decrypted file

twofishEncrypt

public static void twofishEncrypt(java.lang.String passPhrase,
                                  java.io.File inFile,
                                  java.io.File outFile)
Parameters:
passPhrase - Passphrase for TwoFish decryption
inFile - File to encrypt
outFile - Encrypted file

twofishDecrypt

public static void twofishDecrypt(java.lang.String passPhrase,
                                  java.io.File inFile,
                                  java.io.File outFile)
Parameters:
passPhrase - Passphrase for TwoFish decryption
inFile - File to decrypt
outFile - Decrypted file

xteaEncrypt

public static void xteaEncrypt(java.lang.String passPhrase,
                               java.io.File inFile,
                               java.io.File outFile)
Parameters:
passPhrase - Passphrase for XTEA decryption
inFile - File to encrypt
outFile - Encrypted file

xteaDecrypt

public static void xteaDecrypt(java.lang.String passPhrase,
                               java.io.File inFile,
                               java.io.File outFile)
Parameters:
passPhrase - Passphrase for XTEA decryption
inFile - File to decrypt
outFile - Decrypted file

main

public static void main(java.lang.String[] args)
       Usage:
         java com.softabar.crypt.SoftaCryptHelper <command> <argument1> <argument2> ...
       
       Possible commands:
         sha1 -T<text to calculate digest> 
         sha1 <file name to calculate digest>
         sha224 -T<text to calculate digest> 
         sha224 <file name to calculate digest> 
         sha256 -T<text to calculate digest> 
         sha256 <file name to calculate digest> 
         sha384 -T<text to calculate digest> 
         sha384 <file name to calculate digest> 
         sha512 -T<text to calculate digest> 
         sha512 <file name to calculate digest> 
         crc32 -T<text to calculate crc32> 
         crc32 <file name to calculate crc32> 
         base64encode <input file> <output file> 
         base64decode <input file> <output file> 
         aes-encrypt <pass phrase> <input file> <output file> 
         aes-decrypt <pass phrase> <input file> <output file> 
         twofish-encrypt <pass phrase> <input file> <output file> 
         twofish-decrypt <pass phrase> <input file> <output file> 
         xtea-encrypt <pass phrase> <input file> <output file> 
         xtea-decrypt <pass phrase> <input file> <output file> 
 

Parameters:
args -