Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Unable to decrypt string encrypted by the cryptString function

Avatar

Avatar
Validate 1
Level 2
danc13675873
Level 2

Likes

6 likes

Total Posts

19 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
danc13675873
Level 2

Likes

6 likes

Total Posts

19 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
danc13675873
Level 2

12-08-2020

I am trying to decrypt using Java a string encrypted by the cryptString function in Adobe Campaign Classic.

 

 

 

var encryptedString = cryptString (“helloworld”, “{secretKey}”, false);

 

 

I have observed the encrypted string always starts with an @ and is 1 character longer than if I encrypt the same string using Java.

 

The test Java decrypt function looks like:

 

 

 

    public static void main( String[] args ) throws Exception
    {
      String decryptedString = decrypt("{encryptedString}", "{secretKey}");
      System.out.println(decryptedString);  
    }    
public static String decrypt(String encrypted, String secretKey) throws Exception {
      try {
          SecretKeySpec skeySpec = new SecretKeySpec(secretKey.getBytes("UTF-8"), "AES");

          Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
          cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16]));
          byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
   
          System.out.println(new String(original));
      } catch (Exception ex) {
          ex.printStackTrace();
      }
      return null;
  }
   

 

 

 

 

When I run this I get the error:

javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

163 likes

Total Posts

380 posts

Correct Reply

134 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

163 likes

Total Posts

380 posts

Correct Reply

134 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile
Milan_Vucetic
MVP

13-08-2020

Hi @danc13675873

You may use "DESede/ECB/NoPadding" or  "DESede/CBC/NoPadding" instead.

Regards,

Milan