init snippets

This commit is contained in:
jilen 2024-11-02 20:34:57 +08:00
commit cc9255ae51
5 changed files with 137 additions and 0 deletions

14
zd/gen_user_id.scala Normal file
View file

@ -0,0 +1,14 @@
//> using dep com.google.guava:guava:33.3.0-jre
import com.google.common.base.Charsets
import com.google.common.hash.Hashing
@main
def genId(id: String, key: String) = {
val sign = sha256(id + sha256(key))
println(s"${id}|${sign}")
}
def sha256(str: String) = {
Hashing.sha256().hashString(str, Charsets.UTF_8).toString
}