Module: NCipher

Extended by:
Configuration, Convert
Defined in:
lib/n_cipher.rb,
lib/n_cipher/version.rb

Overview

ユニコードエスケープシーケンスを用いた簡易的な暗号化及び復号化方式を提供するモジュール

Defined Under Namespace

Modules: Configuration, Convert

Constant Summary collapse

VERSION =

バージョン番号

'0.4.1'

Instance Attribute Summary

Attributes included from Configuration

#delimiter, #seed

Class Method Summary collapse

Methods included from Convert

convert, convert_table

Methods included from Configuration

configure

Class Method Details

.decode(string, seed: @seed, delimiter: @delimiter) ⇒ String

Note:

このメソッドはNCipher::Convert#convertのラッパーメソッドである

文字列を復号化

Examples:

NCipher.decode('ぱすん〜ぱすぱ〜ぱすす〜', seed: 'にゃんぱす', delimiter: '')#=> "abc"

Raises:

  • (ArgumentError)
  • (TypeError)
  • (RangeError)

See Also:


132
133
134
135
136
137
# File 'lib/n_cipher.rb', line 132

def decode(string, seed: @seed, delimiter: @delimiter)
  [string, seed, delimiter].each do |obj|
    fail TypeError, "Arguments must be respond to 'to_str' method." unless obj.respond_to? :to_str
  end
  convert(:decode, string.to_str, seed.to_str, delimiter.to_str)
end

.encode(string, seed: @seed, delimiter: @delimiter) ⇒ String

Note:

このメソッドはNCipher::Convert#convertのラッパーメソッドである

文字列を暗号化

Examples:

NCipher.encode('abc', seed: 'にゃんぱす', delimiter: '')#=> "ぱすん〜ぱすぱ〜ぱすす〜"

Raises:

  • (ArgumentError)
  • (TypeError)
  • (RangeError)

See Also:


106
107
108
109
110
111
# File 'lib/n_cipher.rb', line 106

def encode(string, seed: @seed, delimiter: @delimiter)
  [string, seed, delimiter].each do |obj|
    fail TypeError, "Arguments must be respond to 'to_str' method." unless obj.respond_to? :to_str
  end
  convert(:encode, string.to_str, seed.to_str, delimiter.to_str)
end