• Register
0 votes

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");
        kgen.init(128, secureRandom);

Further Readings:


36.1k points
edited by

Related questions

0 votes
2 answers 141 views
Problem : Today I installed Java 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 343 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 296 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
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 45 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