java - Hashalgorithm and hashencoding -
i using build in jboss login-module
. has encode user entered password , compare encrypted password in db
.
<module-option name="hashalgorithm" value="md5"/> <module-option name="hashencoding" value="base64"/>
for storing password in db use following line
newuser.setpassword(datatypeconverter.printbase64binary(purepassword.getbytes("utf-8")));
when debug application appears:
- encrypted password db =
mtizndu2nzg=
- encrypted password user login =
jdva0ooqqar0zmdtctwhrq==
questions:
- what happening? when jboss use
base64
algorithm , whenmd5
- what difference between
hashalgorithm
,hashencoding
?
- what happening? when jboss use base64 algorithm , when md5
md5 hash algorithm , base64 output character encoding.
a character encoding defines characters correspond byte or series of bytes.
md5 cryptographic hash algorithm produces 16-byte output of 8-bit bytes, not characters. not 8-bit bytes printable characters.
base64 accepts array of bytes , produces printable character string. used array of bytes needs encoded printable character string.
- what difference between hashalgorithm , hashencoding?
some hash functions allow specification of hash algorithm hashalgorithm
such md5, sha1, sha-256, etc used hash output encoding hashencoding
such hexadecimal or base64. allows 1 function call both hash input selected hash algorithm , selected output encoding in 1 call.
Comments
Post a Comment