Module: NCipher::Helper

Included in:
NCipher
Defined in:
lib/n_cipher.rb

Instance Method Summary collapse

Instance Method Details

#convert_table(string, mode) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/n_cipher.rb', line 5

def convert_table(string, mode)
  table = string.split('').map.with_index(0) {|c,i| [i.to_s, c] }.to_h
  case mode
  when :encode then table
  when :decode then table.invert
  end
end