init snippets
This commit is contained in:
commit
cc9255ae51
5 changed files with 137 additions and 0 deletions
14
zd/gen_user_id.scala
Normal file
14
zd/gen_user_id.scala
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue