com.hejinonline.util.UUID.scala Maven / Gradle / Ivy
The newest version!
package com.hejinonline.util
import scala.math.BigInt
import scala.collection.mutable.ArrayBuffer
object UUID {
def randomUUID(): String = {
val uuid = java.util.UUID.randomUUID()
val buffer = new ArrayBuffer[Byte](4)
buffer ++= BigInt(uuid.getLeastSignificantBits).toByteArray
buffer ++= BigInt(uuid.getMostSignificantBits).toByteArray
Base58.encode(buffer.toArray)
}
}