public class AS400StringEncrypter
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private static javax.crypto.Cipher |
cvDecryptCipher
The cipher for decryption.
|
private static javax.crypto.Cipher |
cvEncryptCipher
The cipher for encryption.
|
private static javax.crypto.spec.SecretKeySpec |
cvKeySpec
The key used for encryption and decryption.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Constructor and Description |
---|
AS400StringEncrypter() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
ascii2ebcdic(java.lang.String s)
Converts an ASCII string to an EBCDIC byte array.
|
static java.lang.String |
decrypt(byte[] b,
java.lang.String iv)
Decrypts the given EBCDIC encoded byte array into an ASCII string.
|
static java.lang.String |
ebcdic2ascii(byte[] b)
Converts an EBCDIC byte array to an ASCII string.
|
static byte[] |
encrypt(java.lang.String s,
java.lang.String iv)
Encrypts the given ASCII string into an EBCDIC encoded byte array.
|
static byte[] |
encrypt(java.lang.String s,
java.lang.String iv,
int len)
Encrypts the given ASCII string into an EBCDIC encoded byte array.
|
static java.lang.String |
getRandomIV()
Returns a random generated initialization vector.
|
static boolean |
isCryptoInstalled()
Answers if the cryptography supporting classes are installed.
|
private static final long serialVersionUID
private static javax.crypto.spec.SecretKeySpec cvKeySpec
private static javax.crypto.Cipher cvEncryptCipher
private static javax.crypto.Cipher cvDecryptCipher
public static java.lang.String decrypt(byte[] b, java.lang.String iv)
encrypt
method of this class or
by the backend ERP system. Returns an empty string if cryptography classes
are not installed.b
- (byte[]) The byte array to be decrypted.iv
- (String) The initialization vector that was originally used
to encrypt the byte array.public static byte[] encrypt(java.lang.String s, java.lang.String iv)
decrypt
method of this class or by the back
end ERP system. Returns an empty byte array if the cryptography classes are
not installed.s
- (String) The string to be encrypted.iv
- (String) The initialization vector to use for encryption.public static byte[] encrypt(java.lang.String s, java.lang.String iv, int len)
decrypt
method of this class or by the back
end ERP system. Returns an empty byte array if the cryptography classes are
not installed.s
- (String) The string to be encrypted.iv
- (String) The initialization vector to use for encryption.len
- (int) The forced length for string to be encrypted. If
necessary, pads or truncates the given string to achieve this
length prior to performing encryption. Padding and truncation is
to the right. A zero (0) indicates no padding or truncating, just
encrypt the given string as is. An empty string is never padded
regardless of this value.public static byte[] ascii2ebcdic(java.lang.String s)
s
- (String) The string to convert.public static java.lang.String ebcdic2ascii(byte[] b)
b
- (byte[]) The byte array to convert.public static java.lang.String getRandomIV()
public static boolean isCryptoInstalled()
true
if the cryptography classes are
installed, otherwise false
.