Loading src/main/java/com/leegality/encryptionDecryptionUtil/EncryptionDecryptionUtil.java +13 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,19 @@ package com.leegality.encryptionDecryptionUtil; public class EncryptionDecryptionUtil { public static void main(String[] args) throws Exception { // This code is for reference purpose only /*Encrypt en = new Encrypt(); EncryptDecryptResponseVO responseVO = en.encrypt("/payoad.txt", "/certificate-key.cer"); System.out.println(responseVO.getPayload()); System.out.println("----------------------------------"); System.out.println(responseVO.getSalt()); Decrypt dec = new Decrypt(); EncryptDecryptResponseVO responseVO1 = dec.decrypt(responseVO.getPayload(), responseVO.getSalt(), "/gspl_test.pfx", "12345678",null); System.out.println(responseVO1.toString());*/ } } src/main/java/com/leegality/encryptionDecryptionUtil/crypto/Decrypt.java +2 −2 Original line number Diff line number Diff line Loading @@ -29,8 +29,8 @@ public class Decrypt { privateKey = SignatureUtil.getPrivateKey(pfxFilePath, password); } String key = EncryptionUtil.decrypt(salt, privateKey); byte[] keyByte = Base64.getDecoder().decode(key); String keyString = EncryptionUtil.decrypt(salt, privateKey); byte[] keyByte = Base64.getDecoder().decode(keyString.getBytes()); byte[] actKey = Arrays.copyOfRange(keyByte, 0, 32); byte[] iv = Arrays.copyOfRange(keyByte, 32, 48); Loading src/main/java/com/leegality/encryptionDecryptionUtil/util/EncryptionUtil.java +2 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ public class EncryptionUtil { public static String encrypt(String rawData, PublicKey publicKey) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(RSA_ECB_PKCS_1_PADDING); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encVal = cipher.doFinal(rawData.getBytes()); byte[] encVal = cipher.doFinal(Base64.decodeBase64(rawData)); return Base64.encodeBase64String(encVal); } Loading @@ -26,7 +26,7 @@ public class EncryptionUtil { Cipher cipher = Cipher.getInstance(RSA_ECB_PKCS_1_PADDING); cipher.init(Cipher.DECRYPT_MODE, privateKey); byte[] decValue = cipher.doFinal(Base64.decodeBase64(rawData)); return new String(decValue); return Base64.encodeBase64String(decValue); } Loading Loading
src/main/java/com/leegality/encryptionDecryptionUtil/EncryptionDecryptionUtil.java +13 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,19 @@ package com.leegality.encryptionDecryptionUtil; public class EncryptionDecryptionUtil { public static void main(String[] args) throws Exception { // This code is for reference purpose only /*Encrypt en = new Encrypt(); EncryptDecryptResponseVO responseVO = en.encrypt("/payoad.txt", "/certificate-key.cer"); System.out.println(responseVO.getPayload()); System.out.println("----------------------------------"); System.out.println(responseVO.getSalt()); Decrypt dec = new Decrypt(); EncryptDecryptResponseVO responseVO1 = dec.decrypt(responseVO.getPayload(), responseVO.getSalt(), "/gspl_test.pfx", "12345678",null); System.out.println(responseVO1.toString());*/ } }
src/main/java/com/leegality/encryptionDecryptionUtil/crypto/Decrypt.java +2 −2 Original line number Diff line number Diff line Loading @@ -29,8 +29,8 @@ public class Decrypt { privateKey = SignatureUtil.getPrivateKey(pfxFilePath, password); } String key = EncryptionUtil.decrypt(salt, privateKey); byte[] keyByte = Base64.getDecoder().decode(key); String keyString = EncryptionUtil.decrypt(salt, privateKey); byte[] keyByte = Base64.getDecoder().decode(keyString.getBytes()); byte[] actKey = Arrays.copyOfRange(keyByte, 0, 32); byte[] iv = Arrays.copyOfRange(keyByte, 32, 48); Loading
src/main/java/com/leegality/encryptionDecryptionUtil/util/EncryptionUtil.java +2 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ public class EncryptionUtil { public static String encrypt(String rawData, PublicKey publicKey) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(RSA_ECB_PKCS_1_PADDING); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encVal = cipher.doFinal(rawData.getBytes()); byte[] encVal = cipher.doFinal(Base64.decodeBase64(rawData)); return Base64.encodeBase64String(encVal); } Loading @@ -26,7 +26,7 @@ public class EncryptionUtil { Cipher cipher = Cipher.getInstance(RSA_ECB_PKCS_1_PADDING); cipher.init(Cipher.DECRYPT_MODE, privateKey); byte[] decValue = cipher.doFinal(Base64.decodeBase64(rawData)); return new String(decValue); return Base64.encodeBase64String(decValue); } Loading