{"id":3555,"date":"2011-10-26T18:12:33","date_gmt":"2011-10-26T18:12:33","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/?p=3555"},"modified":"2011-10-26T18:12:33","modified_gmt":"2011-10-26T18:12:33","slug":"secure-random-strings-in-ruby","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2011\/10\/26\/secure-random-strings-in-ruby\/","title":{"rendered":"Secure random strings in Ruby"},"content":{"rendered":"<p>File this under &#8220;Well-documented features I never noticed before.&#8221; In Ruby, if you need to generate random strings for various purposes, there&#8217;s a native module: <a href=\"http:\/\/rubydoc.info\/stdlib\/securerandom\/1.9.2\/SecureRandom\">SecureRandom<\/a>.<\/p>\n<p>In Ruby 1.8, you can generate Base-64-encoded strings, hex, random numbers (integers), and random bytes. Ruby 1.9 adds the ability to generate UUIDs and URL-safe Base64 strings. Really simple, and not particularly interesting &#8212; unless, like me, you found yourself thinking you had to write this functionality yourself.<\/p>","protected":false},"excerpt":{"rendered":"<p>File this under &#8220;Well-documented features I never noticed before.&#8221; In Ruby, if you need to generate random strings for various purposes, there&#8217;s a native module: SecureRandom. In Ruby 1.8, you can generate Base-64-encoded strings, hex, random numbers (integers), and random &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2011\/10\/26\/secure-random-strings-in-ruby\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-3555","post","type-post","status-publish","format-standard","hentry","category-rails"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/3555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=3555"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/3555\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=3555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=3555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=3555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}