Assigning Each User a Unique 100 character Hash in Ruby on Rails

后端 未结 3 1184
北海茫月
北海茫月 2021-02-03 12:22

I have a form on a website that takes in some personal information from the visitor. I\'m passing this information to another service and I need to assign each one of these for

3条回答
  •  情书的邮戳
    2021-02-03 12:40

    The Ruby standard lib has a module for generating GUIDs:

    http://ruby-doc.org/stdlib/libdoc/digest/rdoc/classes/Digest/SHA2.html

    Example:

    Digest::SHA1.hexdigest(Time.now.to_s)
    

提交回复
热议问题