Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (27 sloc) 0.872 kb
package play.api.libs
import javax.crypto._
import javax.crypto.spec.SecretKeySpec
import play.api.Play
import play.api.PlayException
* Cryptographic utilities.
object Crypto {
* Signs the given String with HMAC-SHA1 using the given key.
def sign(message: String, key: Array[Byte]): String = {
val mac = Mac.getInstance("HmacSHA1")
mac.init(new SecretKeySpec(key, "HmacSHA1"))
* Signs the given String with HMAC-SHA1 using the application’s secret key.
def sign(message: String): String = {
Play.maybeApplication.flatMap(_.configuration.getString("application.secret")).map(secret => sign(message, secret.getBytes)).getOrElse {
throw PlayException("Configuration error", "Missing application.secret")
Jump to Line
Something went wrong with that request. Please try again.