Unit testing of BCryptPasswordEncoder hashed password

前端 未结 2 671
傲寒
傲寒 2021-01-22 23:13

In spring 5, I am using BCryptPasswordEncoder for password hashing. My code looks like below

@Autowired
private BCryptPasswordEncoder passwordEncoder;

2条回答
  •  庸人自扰
    2021-01-22 23:46

    The user you are getting from your repository has a different password. See the org.junit.ComparisonFailure message.

    passwordEncoder.encode("myPassword") returns $2[a$10$EulgXiN/bEwjJZc2IqRgoOyTcJWNZp0STtgY0fZv9XSIWigMHiBN2]

    while your user has $2[y$12$Q3BUtijkUb.HdXsYbS9rCuaCcQE0/VdU2YC.N18uZB7jZ4/r0DSzO]

提交回复
热议问题