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:

  1. what happening? when jboss use base64 algorithm , when md5
  2. what difference between hashalgorithm , hashencoding?

  1. 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.

  1. 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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -