Generating Guids in Ruby

后端 未结 10 1879
南笙
南笙 2020-11-27 10:53

I have problem that is really easily solved with Guids.

In particular, for a password reset workflow, I would like to send a Guid token to a user\'s email and have

10条回答
  •  孤街浪徒
    2020-11-27 11:43

    Small update to Simone Carletti answer:

    SecureRandom.base64(8).gsub("/","_").gsub(/=+$/,"")

    => "AEWQyovNFo0"

    can be replaced with:

    SecureRandom.urlsafe_base64(8)

提交回复
热议问题