1

Spring Bcrypt is not working in my Web Application. I've Spring 3.1.0 version in my application. Here I'm sharing some sample code what I tried.

BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
System.out.println(encoder.matches(pwd, dbpwd));

It prints false even if I enter correct password. But some times if I enter wrong password it prints true. I'm saving encoding password in Database after encode

pwd = new BCryptPasswordEncoder().encode(pwd);

Why it's behaving in different ways. Am I missing anything here. Please correct me if I did wrong.

nay
  • 95
  • 12

1 Answers1

0

I suspect that your field in your database is not long enough.

You need at least a CHAR(60) BINARY or BINARY(60), or you will lose data.

Related post here.

Community
  • 1
  • 1
kagmole
  • 2,005
  • 2
  • 12
  • 27
  • Issue is not with size. I've column size of `60` in table. Still I'm unable to find what's the exact issue. – nay Mar 24 '17 at 07:43