public static String digestSha1Hex ( String source ) { String sha1 = "" ; try { MessageDigest crypt = MessageDigest . getInstance ( "SHA-1" ) ; crypt . reset ( ) ; crypt . update ( source . getBytes ( "UTF-8" ) ) ; sha1 = byteToHex ( crypt . digest ( ) ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } return sha1 ; }
Hashes the source with SHA1 and returns the resulting hash as an hexadecimal string .