4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Kotlinで短いUUIDを作成する方法

Last updated at Posted at 2018-12-13
  • UUIDと、mdハッシュ値のコンボでOK.
import java.util.UUID
import org.apache.commons.codec.digest.DigestUtils

fun main(args: Array<String>) {
  println(DigestUtils.md2Hex(UUID.randomUUID().toString())
}

結果:

DigestUtils.md2Hexで生成した場合、

d11kw4tdgfdgd

実用的には、md5を使う(桁数の観点で):
DigestUtils.md5Hexで生成した場合、

537d4266d399a71bb5a22e338a98a073
4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?