3 Replies Latest reply on Nov 9, 2017 1:49 AM by chidrewar.rohit

    How to decrypt the password which was encrypted by picketBox

    yangguang

      In JBoss AS7 datasource configuration, I use java org.picketbox.datasource.security.SecureIdentityLoginModule passwordString to encrypt the password.

      Now I have one requirement that decrypt the password by my app code. Could anybody tell me How to do it?

        • 1. Re: How to decrypt the password which was encrypted by picketBox
          sfcoy

          Everything you need to know can be found in org.picketbox.datasource.security.SecureIdentityLoginModule

           

          Isn't open source wonderful?

          1 of 1 people found this helpful
          • 2. Re: How to decrypt the password which was encrypted by picketBox
            yangguang

            Yes, thanks for help. I think I can investigate.

            • 3. Re: How to decrypt the password which was encrypted by picketBox
              chidrewar.rohit

              Yes you can do this by ---->

               

              /**

              * @author Rohit

              *

              */

              public class DecodePassword{

               

                    public static void main(String[] args)

                    {

                      String value = null;

                      if (args.length < 0) {

                        System.out.println("Necessary arguments Not passed,Please Pass the Password To Decrypt");

                      } else {

                        value = args[0].toString().trim();

                      }

                      try

                      {

                        System.out.println(decode(value));

                      }

                      catch (Exception io)

                      {

                        io.printStackTrace();

                      }

                    }

                 

                public static char[] decode(String secret)

                      throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException

                    {

                      byte[] kbytes = "jaas is the way".getBytes();

                      SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");

                     

                      BigInteger n = new BigInteger(secret, 16);

                      byte[] encoding = n.toByteArray();

                     

                      Cipher cipher = Cipher.getInstance("Blowfish");

                      cipher.init(2, key);

                      byte[] decode = cipher.doFinal(encoding);

                      return new String(decode).toCharArray();

                    }

               

              }