1
0

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.

Digest::UUID見てみたのでメモ

公式ドキュメント

概要

定義されているメソッドは以下の3つでそれぞれハッシュ関数が違います。

  • self.uuid_v3
    -> Digest::MD5を使用
  • self.uuid_v4
    -> SecureRandom.uuidの簡易メソッド。
  • self.uuid_v5
    -> Digest::SHA1を使用
$ Digest::UUID.uuid_v4
=> "4ad2a6a9-0135-4158-94d3-a33e41bbe048"

$ Digest::UUID.uuid_v3("name_space", "sample")
=> "3b0ead59-ca8d-350b-a392-e656db58b0fc"

$ Digest::UUID.uuid_v5("name_space", "sample")
=> "d7a9ae1a-b099-5318-8828-340cc10a1550"

rails -v

$ bundle exec rails -v
Rails 6.0.2.rc1
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?