Module: NCipher
- Extended by:
- ArgumentValidation
- Defined in:
- lib/n_cipher.rb,
lib/n_cipher/version.rb,
lib/n_cipher/argument_validation.rb
Defined Under Namespace
Modules: ArgumentValidation
Classes: Configuration
Constant Summary
collapse
- VERSION =
'0.5.1'
Class Method Summary
collapse
around_alias, define_proxy_method, included, store_validation, validations
Class Method Details
.config ⇒ Object
38
39
40
|
# File 'lib/n_cipher/configuration.rb', line 38
def config
@config ||= NCipher::Configuration.new
end
|
42
43
44
|
# File 'lib/n_cipher/configuration.rb', line 42
def configure(&block)
block.call(config)
end
|
.decode(string) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# 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) ⇒ Object
9
10
11
12
13
14
15
16
|
# 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
|