• Register
0 votes
113 views

Problem :

I am trying to implement password based encryption algorithm, but I get this 

javax.crypto.badpaddingexception: given final block not properly padded

6.9k points

1 Answer

0 votes

Solution :

I had this issue due to my operating system, it is different to different platforms , its all about JRE implementation.

        new SecureRandom(key.getBytes())

will give the value in Windows, But it is different in Linux. So in Linux you need to change it to

        SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
        secureRandom.setSeed(key.getBytes());
        kgen.init(128, secureRandom);

Further Readings:

https://github.com/nelenkov/android-backup-extractor/issues/46

36.1k points
edited by

Related questions

0 votes
2 answers 139 views
139 views
Problem : Today I installed Java 1.6.0.26 on my server user and when I try to run my application, I get the following exception. java.security.invalidkeyexception illegal key size or default parameters
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 332 views
332 views
Problem : I want to input some of the details about student to my program. But when I press a save button its giving me the below listed exception error: "Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet."
asked Jan 31 jwilliam 3.9k points
0 votes
1 answer 285 views
285 views
Problem : I am getting bellow error while I try to connect MySql database with Java using connector 8.0.11 java.sql.sqlnontransientconnectionexception: public key retrieval is not allowed
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 23 views
23 views
Problem : I am new to C#. I want to know how can I get the value of a given key in a following exception which I am currently facing in C# in a way it affects all the generic classes? Below is the exception which I am currently facing. "The given key was not present in the dictionary." How to fix above exception.
asked Feb 24 mphil 2.3k points
1 vote
2 answers 41 views
41 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 27 LizzyM 6.1k points