add catch for invalid hash
add SecureRandom
use new SecureRandom class