Commit e57faa33 authored by Lakshay Thakur's avatar Lakshay Thakur
Browse files

changes for encoding changes in main app.

parent f4ffd61a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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());*/
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -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);

+2 −2
Original line number Diff line number Diff line
@@ -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);
    }

@@ -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);
    }