module NCipher
Constants
- VERSION
バージョン番号
Public Class Methods
config()
click to toggle source
# File lib/n_cipher/configuration.rb, line 38 def config @config ||= NCipher::Configuration.new end
configure(&block)
click to toggle source
# File lib/n_cipher/configuration.rb, line 42 def configure(&block) block.call(config) end
decode(string)
click to toggle source
# File lib/n_cipher.rb, line 18 def decode(string) string .to_str .split(NCipher.config.delimiter) .map {|char| char.gsub(/./, convert_table(:for => :decode)) } .map {|char| char.to_i(NCipher.config.seed.length) } .map {|char| [char].pack('U') } .join end
encode(string)
click to toggle source
# File lib/n_cipher.rb, line 9 def encode(string) string .to_str .unpack('U*') .map {|char| char.to_s(NCipher.config.seed.length) } .map {|char| char.gsub(/./, convert_table(:for => :encode)) } .join(NCipher.config.delimiter) end
Private Class Methods
convert_table(param={:for => nil})
click to toggle source
# File lib/n_cipher.rb, line 46 def convert_table(param={:for => nil}) table = [*'0'..'9', *'a'..'z'].zip(NCipher.config.seed).reject(&:one?).to_h case param[:for] when :encode then table when :decode then table.invert end end