com.wizzardo.tools.security
Class Hash

java.lang.Object
  extended by com.wizzardo.tools.security.Hash
Direct Known Subclasses:
MD5, SHA1, SHA256

public abstract class Hash
extends java.lang.Object

Created by wizzardo on 12.03.15.


Constructor Summary
Hash(java.lang.String name)
           
 
Method Summary
 byte[] asBytes()
           
 void asBytes(byte[] bytes)
           
 void asBytes(byte[] bytes, int offset)
           
 java.lang.String asString()
           
 boolean check(byte[] b, byte[] hashBytes)
          get hash from given bytes and check for equals it with hashBytes
 boolean check(java.lang.String value, java.lang.String hashString)
          get hash from given string and check for equals it with hashString
protected abstract  int hexStringLength()
           
protected  java.security.MessageDigest init(java.lang.String name)
           
 Hash reset()
           
 java.lang.String toString()
           
 Hash update(byte b)
           
 Hash update(byte[] b)
           
 Hash update(byte[] b, int offset, int length)
           
 Hash update(java.io.InputStream in)
           
 Hash update(java.lang.String s)
          update hash with getBytes(UTF8)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hash

public Hash(java.lang.String name)
Method Detail

init

protected java.security.MessageDigest init(java.lang.String name)

hexStringLength

protected abstract int hexStringLength()

update

public Hash update(byte[] b,
                   int offset,
                   int length)

reset

public Hash reset()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

update

public Hash update(byte[] b)

update

public Hash update(java.lang.String s)
update hash with getBytes(UTF8)


update

public Hash update(byte b)

asString

public java.lang.String asString()
Returns:
hash as hex string

asBytes

public byte[] asBytes()
Returns:
hash as bytes

asBytes

public void asBytes(byte[] bytes)

asBytes

public void asBytes(byte[] bytes,
                    int offset)

update

public Hash update(java.io.InputStream in)
            throws java.io.IOException
Throws:
java.io.IOException

check

public boolean check(java.lang.String value,
                     java.lang.String hashString)
get hash from given string and check for equals it with hashString


check

public boolean check(byte[] b,
                     byte[] hashBytes)
get hash from given bytes and check for equals it with hashBytes