3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cipher/generator.rb', line 3
def generate(args = {})
@key_length ||= args[:key_length]
@section_length ||= args[:section_length]
@seperator ||= args[:seperator]
unique = args[:unique]
output = ''
i = 0
if unique.nil?
raise ArgumentError, 'You need to pass a hash with a unique to generate a key'
end
while i < (@key_length/@section_length).ceil do
output << hash(unique + i.to_s)[0..@section_length-1] + @seperator
i += 1
end
output[0..-@seperator.length-1].upcase
end
|