random keygen

For general discussion related FlowStone
Post Reply
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

random keygen

Post by Nubeat7 »

after some research i found this code:

Code: Select all

(0..@lenght).to_a.map{|a| rand(16).to_s(16)}.join

to generate random keys like are used for serial or product keys...
i simply run a loop and save it in an array, like this my computer is able to generate up to 30 000 keys (ruby module turns off with 50 000...

it would be useful to provide a list of pruduct keys for purchasing custumors of your software product(to get updates with the key) or maybe also for a simple protection system...

my question now is, are the generated numbers unique in this code?

how to bulid a guid / uuid keygen? found some codes about "SecureRandom" can this be used in FS?

some link about: http://stackoverflow.com/questions/1117 ... ds-in-ruby
Attachments
randomKeyGen.fsm
(14.14 KiB) Downloaded 952 times
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: random keygen

Post by Tronic »

if you do not have to use it to the plugins (because now they can no longer recall, external extensions)
it can be created using Win32API.
only with the ruby is not effectively secure and unique.

Code: Select all

require 'Win32API'
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa379205(v=vs.85).aspx
@api = Win32API.new('rpcrt4', 'UuidCreate', 'P', 'L')

buffer = ' ' * 16
@api.call(buffer)

a, b, c, d, e, f, g, h = buffer.unpack('SSSSSSSS')
uuid = a, b, c, d, e, f, g, h  # => [33474, 814, 35932, 17755, 31113, 32122, 12955, 9560]
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: random keygen

Post by Nubeat7 »

thanks tronic, but looks like this one has just 5 digits and only numbers so i think its not very secure with 100 000 possibilities, i really dont get how this is working how should a 5 digit number be universal unique? here i also tried another library but with the same effect, or is every letter in your example one part of the uuid?

Code: Select all

    require 'Win32API'
    @api = Win32API.new('ole32', 'CoCreateGuid', 'P', 'S')
    buffer = ' ' * 16
    @api.call(buffer)
    uuid = buffer.unpack('SSSSSSSS')


if so how can i get it in a format with letters too like these classic serials like jK39-o7U2-287b-kjh5 with 0..9, A..Z, a..z included

like the example in my first post but i don`t know if keys are repeating with this code?
i mean when i use

Code: Select all

output p.uniq 
instead of

Code: Select all

output p
all the generated key are unique, what doesnt mean that they are universal unique identifiers?
Post Reply