Belajar pemrograman Ruby: Secure Random

Tulisan sebelumnya membahas ‘Belajar Pemrograman Ruby: Timeout

Secure Random merupakan modul Ruby yang digunakan untuk menghasilkan nilai acak.

Contoh 1

require 'securerandom'
require 'hex_string'

begin
	acak = SecureRandom.random_bytes(5)
	puts acak.to_hex_string
end

Output

db a5 37 7b 38

Output akan selalu berbeda karena nilai acak.

Jika gagal dalam kompilasi, pasang terlebih dahulu modul hex_string.

gem install hex_string

Keep Fun Coding 😀

Advertisements

2 thoughts on “Belajar pemrograman Ruby: Secure Random

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s