public class SecurityExtension extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
SecurityExtension.Ciphertext |
static class |
SecurityExtension.RSAKey |
| Constructor and Description |
|---|
SecurityExtension() |
| Modifier and Type | Method and Description |
|---|---|
static String |
DESDecrypt(String input,
String encryptionKey) |
static String |
DESDecrypt(String encryptionSchema,
String input,
String encryptionKey,
String encoding)
DESDecrypt
|
static String |
DESEncrypt(String input,
String encryptionKey) |
static String |
DESEncrypt(String encryptionSchema,
String input,
String encryptionKey,
String encoding)
DESEncrypt
|
static PublicKey |
getPublicKeyFromBase64(String base64PublicKeyFile) |
static PublicKey |
getPublicKeyFromHex(String hexPublicKey) |
static String |
RSADecrypt(BigInteger text,
PrivateKey key) |
static String |
RSADecrypt(byte[] text,
PrivateKey key) |
static String |
RSADecryptFromBase64(String base64Text,
PrivateKey key) |
static String |
RSADecryptFromHex(String hexText,
PrivateKey key) |
static SecurityExtension.Ciphertext |
RSAEncrypt(byte[] text,
PublicKey key) |
static SecurityExtension.Ciphertext |
RSAEncrypt(String text,
PublicKey key) |
static SecurityExtension.RSAKey |
RSAGenerateKey(int keySize)
RSAGenerateKey
|
static void |
RSAGenerateKey(int keySize,
File privateKeyFile,
File publicKeyFile) |
static PrivateKey |
RSAGetPrivateKey(byte[] privateKeyBinary) |
static PrivateKey |
RSAGetPrivateKey(File privateKeyFile) |
static PrivateKey |
RSAGetPrivateKeyFromBase64(String base64PrivateKey) |
static PrivateKey |
RSAGetPrivateKeyFromHex(String hexPrivateKey) |
static PublicKey |
RSAGetPublicKey(byte[] publicKeyBinary) |
static PublicKey |
RSAGetPublicKey(File publicKeyFile) |
public static final String ALGORITHM
public static String DESEncrypt(String encryptionSchema, String input, String encryptionKey, String encoding)
encryptionSchema - DES or DESedeinput - input stringencryptionKey - keyencoding - utf-8public static String DESDecrypt(String encryptionSchema, String input, String encryptionKey, String encoding)
encryptionSchema - DES or DESedeinput - input stringencryptionKey - keyencoding - utf-8public static void RSAGenerateKey(int keySize,
File privateKeyFile,
File publicKeyFile)
throws NoSuchAlgorithmException,
IOException
NoSuchAlgorithmExceptionIOExceptionpublic static SecurityExtension.RSAKey RSAGenerateKey(int keySize) throws NoSuchAlgorithmException
keySize - 512 or 1024, depends on your encrypt string lengthNoSuchAlgorithmExceptionpublic static PublicKey RSAGetPublicKey(byte[] publicKeyBinary) throws NoSuchAlgorithmException, InvalidKeySpecException
public static PublicKey RSAGetPublicKey(File publicKeyFile) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException, ClassNotFoundException
public static PublicKey getPublicKeyFromBase64(String base64PublicKeyFile) throws IOException, ClassNotFoundException, InvalidKeySpecException, NoSuchAlgorithmException
public static PublicKey getPublicKeyFromHex(String hexPublicKey) throws IOException, ClassNotFoundException, InvalidKeySpecException, NoSuchAlgorithmException
public static SecurityExtension.Ciphertext RSAEncrypt(String text, PublicKey key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException
public static SecurityExtension.Ciphertext RSAEncrypt(byte[] text, PublicKey key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException
public static PrivateKey RSAGetPrivateKey(File privateKeyFile) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionpublic static PrivateKey RSAGetPrivateKey(byte[] privateKeyBinary) throws IOException, ClassNotFoundException, InvalidKeySpecException, NoSuchAlgorithmException
public static PrivateKey RSAGetPrivateKeyFromBase64(String base64PrivateKey) throws IOException, ClassNotFoundException, InvalidKeySpecException, NoSuchAlgorithmException
public static PrivateKey RSAGetPrivateKeyFromHex(String hexPrivateKey) throws IOException, ClassNotFoundException, InvalidKeySpecException, NoSuchAlgorithmException
public static String RSADecryptFromBase64(String base64Text, PrivateKey key) throws UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException
public static String RSADecryptFromHex(String hexText, PrivateKey key) throws UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException
public static String RSADecrypt(byte[] text, PrivateKey key) throws UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException
public static String RSADecrypt(BigInteger text, PrivateKey key) throws UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException
Copyright © 2016. All rights reserved.