|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.asiapeak.ezpgp4j.PGP4j
public class PGP4j
PGP Class for PGP Encryption
If the method needs a file, you should specify it to the full path file name, otherwise it is treated as relative to current folder
This class uses ezpgp.ini as configuration file, you should specify it in constructor, or use default ezpgp.ini in user profile folder.
This class also needs a log4j configuration file. you can specify it with "ezConf" variable in JVM, or it is ezpgpc.conf in current directory
Constructor Summary | |
---|---|
PGP4j()
Constructor Use "%USERPROFILE%\\ezpgp.ini" as configuration file |
|
PGP4j(java.lang.String iniFile)
Constructor |
Method Summary | |
---|---|
int |
ezChangePass(java.lang.String keyName,
java.lang.String oldPass,
java.lang.String newPass)
Change password of a key |
int |
ezClearSign(java.lang.String inFile,
java.lang.String outFile,
java.lang.String signKey,
java.lang.String passWord)
Sign a file then output a signature file |
int |
ezDecryptFile(java.lang.String inFile,
java.lang.StringBuilder outName,
java.lang.String pass,
java.lang.String outDir)
Decrypt a file and get its original file name |
int |
ezDecryptFile(java.lang.String inFile,
java.lang.String outFile,
java.lang.String pass)
Decrypt a file (and verify it if it was signed) |
int |
ezEncryptFile(java.lang.String inFile,
java.lang.String outFile,
java.lang.String keys)
Encrypt a file |
int |
ezEncryptSign(java.lang.String inFile,
java.lang.String outFile,
java.lang.String keys,
java.lang.String signKey,
java.lang.String passWord)
Encrypt and sign a file |
java.lang.String |
ezGetErrMsg(int rc)
Get error message |
int |
ezKeyDelete(java.lang.String keyFpr)
Delete a key |
int |
ezKeyExport(java.lang.String keyName,
java.lang.String fileName,
java.lang.Boolean keyPair)
Export a PGP key |
int |
ezKeyGen(java.lang.String usrName,
java.lang.String eMail,
java.lang.String keyType,
int keyLen,
int days,
java.lang.String pwd)
generate a PGP key pair |
int |
ezKeyImport(java.lang.String keyFile)
Import a key file |
java.util.List<PGPkeys> |
ezListKeys(java.lang.String keyName,
java.lang.Boolean bPub)
List PGP keys |
int |
ezListKeys(java.lang.StringBuffer allkeys)
List all keys |
int |
ezVerify(java.lang.String signFile,
java.lang.String inFile)
Verify the signature file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PGP4j()
Use "%USERPROFILE%\\ezpgp.ini" as configuration file
public PGP4j(java.lang.String iniFile)
iniFile
- configuration file
The confifuration file has the windows ini file format, the below examples are needed
keydir=C:\\test\\ezpgp\\keys
logfile=C:\\test\\ezpgp\\logs\\ezpgplog.txt
license=7D6791DACFDE1A9FDA17A38B66FBA014 (You should get valid license and put it here)
Method Detail |
---|
public java.lang.String ezGetErrMsg(int rc)
rc
- return code of your last command
public int ezEncryptFile(java.lang.String inFile, java.lang.String outFile, java.lang.String keys)
inFile
- input file to encryptoutFile
- output file of the encrypted filekeys
- PGP keys, separated by ";" if multiple keys
0
success others
failedpublic int ezEncryptSign(java.lang.String inFile, java.lang.String outFile, java.lang.String keys, java.lang.String signKey, java.lang.String passWord)
inFile
- input file to encrypt and signoutFile
- output file of the encrypted and signed filekeys
- PGP keys, separated by ";" if multiple keyssignKey
- signing keypassWord
- password of the signing key
0
success others
failedpublic int ezClearSign(java.lang.String inFile, java.lang.String outFile, java.lang.String signKey, java.lang.String passWord)
inFile
- input file to signoutFile
- output signature filesignKey
- signing keypassWord
- password of the signing key
0
success others
failedpublic int ezDecryptFile(java.lang.String inFile, java.lang.String outFile, java.lang.String pass)
inFile
- input file to decryptoutFile
- output file of the decryption filepass
- password of the decryption key (private key)
0
success others
failedpublic int ezDecryptFile(java.lang.String inFile, java.lang.StringBuilder outName, java.lang.String pass, java.lang.String outDir)
inFile
- input file to decryptoutName
- output file name (the orignal name of the input file before it was encrypted)pass
- password of the decryption key (private key)outDir
- output directory to save the output file
0
success others
failedpublic int ezVerify(java.lang.String signFile, java.lang.String inFile)
signFile
- input signature fileinFile
- input file to verify its signature file
0
success others
failedpublic int ezKeyExport(java.lang.String keyName, java.lang.String fileName, java.lang.Boolean keyPair)
keyName
- key namefileName
- the file name to store the key contentkeyPair
- true if export key pair, false if export public key only.
0
success others
failedpublic int ezKeyImport(java.lang.String keyFile)
keyFile
- key file
0
success others
failedpublic int ezChangePass(java.lang.String keyName, java.lang.String oldPass, java.lang.String newPass)
keyName
- key nameoldPass
- old passwordnewPass
- new password
0
success others
failedpublic int ezKeyDelete(java.lang.String keyFpr)
keyFpr
- key finger print, with 40 bytes of hex string
0
success others
failedpublic int ezKeyGen(java.lang.String usrName, java.lang.String eMail, java.lang.String keyType, int keyLen, int days, java.lang.String pwd)
usrName
- user nameeMail
- eMailkeyType
- key type, must be "RSA" or "DSA"keyLen
- key length (in bits, e.g 1024,2048)days
- expired days, 0 is never expiredpwd
- password of the key
0
success others
failedpublic int ezListKeys(java.lang.StringBuffer allkeys)
allkeys
- the buffer to keep all keys
0
success others
failedpublic java.util.List<PGPkeys> ezListKeys(java.lang.String keyName, java.lang.Boolean bPub)
keyName
- key name, if null it is to list all keysbPub
- true for list public keys, false for list private keys
0
success others
failed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |