hey guys i've had this issue for a while but i'm coming closer to solving the issue.
what i m trying to do is i am trying to convert a string to sha-256 which i can do but the string that my java code is not the same as what i get from linux
linux:
echo adam | sha256sum
sum: f3fd8f664c016fec4372773c6b6ac06d0789857297b2473bcd 33fba523dad5fc
java:
sum: f7f376a1fcd0d0e11a10ed1b6577c99784d3a6bbe669b1d13f ae43eb64634f6eCode:MessageDigest md = MessageDigest.getInstance("SHA-256"); byte[] hash = md.digest(consumer.getConsumerPassword().getBytes()); StringBuffer sb = new StringBuffer(); for(byte b : hash) { sb.append(String.format("%02x", b)); }
the two sum's are similar but i don't understand why???
also what should spring security be expecting as far as format for sha-256 if i have this in the spring security file?
Code:<authentication-manager alias="authenticationManager"> <!-- DAO Based Security --> <authentication-provider> <password-encoder hash="sha-256" /> <jdbc-user-service data-source-ref="dataSource" users-by-username-query="SELECT A.username AS username, A.password AS password, A.enabled AS enabled FROM admin A where A.username=?" authorities-by-username-query="SELECT A.username as username, A.password as password, R.name as authority FROM admin A left join admin_roles AR on A.id=AR.admin left join roles R on AR.roles = A.id WHERE A.username=?" /> </authentication-provider> </authentication-manager>


Reply With Quote