Create an empty string or a pre-fix if require:
myStr = "OID-"
Use this code to populate the string with random numbers:
begin; n = ((rand * 43) + 47).ceil; myStr << n.chr if !(58..64).include?(n); end while(myStr.length < 12)
Notes:
(rand * 43) + 47).ceil
It will generate random numbers from 48-91 (0,1,2..Y,Z)
!(58..64).include?(n)
It is used to skip special characters (as I am not interested to include them)
while(myStr.length < 12)
It will generate total 12 characters long string including prefix.
Sample Output:
"OID-XZ2J32XM"