ruby - Generate Unique Random String With Letters And Numbers In Lower Case -
how can fix code generates unique random letters , numbers in lower case?
api_string = (0...32).map{65.+(rand(25)).chr}.join
at moment, generates letters.
if using ruby 1.9.2 can use securerandom:
irb(main):001:0> require 'securerandom' => true irb(main):002:0> securerandom.hex(13) => "5bbf194bcf8740ae8c9ce49e97" irb(main):003:0> securerandom.hex(15) => "d2413503a9618bacfdb1745eafdb0f" irb(main):004:0> securerandom.hex(32) => "432e0a359bbf3669e6da610d57ea5d0cd9e2fceb93e7f7989305d89e31073690"
Comments
Post a Comment