Created
September 14, 2009 20:42
-
-
Save dgalarza/186915 to your computer and use it in GitHub Desktop.
Simulate creating 10 random IP numbers, converted to Hexadecimal string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uses built in ruby functions to handle conversions etc | |
# Create 10 IPs | |
for ips in 1...10 | |
ip = "" | |
#generate a random segment for each IP part (4 parts for each IP) | |
for segment in 1...4 | |
ip += rand(255).to_s(16).upcase | |
end | |
puts ip | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment