• Register
0 votes
133 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 5 3
6,930 points

Please log in or register to answer this question.

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

9 7 4
38,600 points

Related questions

0 votes
2 answers 236 views
236 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 32 views
32 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, 2020 mphil 2.3k points
0 votes
1 answer 826 views
826 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, 2020 jwilliam 3.9k points
0 votes
1 answer 582 views
582 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
1 vote
1 answer 73 views
73 views
Problem : I am a Computer Science student. I am trying to learn Java Programming in this Covid19 lockdown period. I want to write a program which should perform the below task. “Write a java program to count number of characters in given string”. Please let me know the exact procedure to write the above mentioned program.
asked May 19, 2020 Martin K 6.6k points
0 votes
1 answer 18 views
18 views
I need to find frequency of charts in a string? can anyone here help me?
asked Sep 22, 2020 Daniel Anderson 4k points
1 vote
2 answers 119 views
119 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, 2020 LizzyM 6.1k points
2 votes
1 answer 30 views
30 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 24, 2020 LizzyM 6.1k points
0 votes
2 answers 243 views
243 views
Problem : Currently I am working on my app for Android but I am getting following error while working with the SharedPreferences. I am very new to Android App Programming. I am trying to debug it from past 2 days but unable to find the solution ... " android:inputType="number" android:key="capitalownership" android:title="@string/capitalownership" /> Can somebody help me in resolving this error?
asked Feb 17, 2020 mphil 2.3k points
0 votes
1 answer 849 views
849 views
Problem : I am facing a problem with the exception handling in Java, following is my code. I am facing compiler error when I try to execute my code. The error is as below: exception MojException is never thrown in body of corresponding try ... MyMojException: public class MyMojException extends Exception{ MyMojException(String str){ super(str); } } Can anyone suggest solution on my issue?
asked Dec 5, 2019 alecxe 7.5k points