I would like to base64 encode a generated SHA-1 hash in Scala using Play Framework.
This works for me in Scala:
val md = java.security.MessageDigest.getInstance("SHA-1");
println(new sun.misc.BASE64Encoder().encode(md.digest("Foo".getBytes)))
But in Play Framework I get an error using:
type encode is not a member of object sun.misc.BASE64Encoder
when using:
val md = java.security.MessageDigest.getInstance("SHA-1")
val ha = new sun.misc.BASE64Encoder.encode(md.digest(params.get("Foo").getBytes))
How can I generate a SHA-1 hash and base64 encode it using Scala and Play Framework?
You seem to have forgotten a pair of parenthesis:
val md = java.security.MessageDigest.getInstance("SHA-1")
val ha = new sun.misc.BASE64Encoder().encode(md.digest(params.get("Foo").getBytes))
That should work better.