Reputation: 1843
I'm inserting users into a H2 database as follows:
insert into users (id,username,password) VALUES(1,'user','password');
I'm also using spring security. Usually to hash passwords I'd configure Spring like this:
<bean id = "encoder" class = "org.springframework.security.crypto.password.StandardPasswordEncoder"/>
<security:authentication-manager>
<security:authentication-provider user-service-ref="userService">
<security:password-encoder ref="encoder" />-->
</security:authentication-provider>
</security:authentication-man
and put a hash function into the insert statement. The H2 documentation suggests I need to do this:
insert into users (id,username,password) VALUES(1 vg,'user',HASH('SHA256', STRINGTOUTF8('Password'), 1000));
but when I do, the passwords don't seem to match. I expect I'm not configuring something properly, but google isn't helping me.
Upvotes: 0
Views: 1833
Reputation: 47290
Do the convesion in java, using spring
final StandardPasswordEncoder encoder = new StandardPasswordEncoder();
String hashedPassword = encoder.encode(aStringVarOfThePassword);
Upvotes: 1