Computing the MD5 hash of a string in scala [duplicate]

You may be reinventing a very tiny wheel here, but just write a function to do what you want: take a string, use MessageDigest, and return whatever (hex string, byte array) you need.

import java.security.MessageDigest

def md5(s: String) = {
    MessageDigest.getInstance("MD5").digest(s.getBytes)
}

md5("Hello")

P.S. I don’t write Scala, but this works and it’s left as an exercise to the reader to turn it into anything other than an Array[Byte]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)