mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
24 lines
598 B
Scala
24 lines
598 B
Scala
package util
|
|
|
|
import java.net.{URLDecoder, URLEncoder}
|
|
|
|
object StringUtil {
|
|
|
|
def sha1(value: String): String = {
|
|
val md = java.security.MessageDigest.getInstance("SHA-1")
|
|
md.update(value.getBytes)
|
|
md.digest.map(b => "%02x".format(b)).mkString
|
|
}
|
|
|
|
def md5(value: String): String = {
|
|
val md = java.security.MessageDigest.getInstance("MD5")
|
|
md.update(value.getBytes)
|
|
md.digest.map(b => "%02x".format(b)).mkString
|
|
}
|
|
|
|
def urlEncode(value: String): String = URLEncoder.encode(value, "UTF-8")
|
|
|
|
def urlDecode(value: String): String = URLDecoder.decode(value, "UTF-8")
|
|
|
|
}
|