n_cipher 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/n_cipher +13 -15
- data/lib/n_cipher/version.rb +1 -1
- data/lib/n_cipher.rb +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55856584bfc84a9712668f10e66ffedc63298846
|
4
|
+
data.tar.gz: 55913d58805b7e3663f85825e11694eb7d43bd5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5582c0208aa3a7a719b1fec115026b40ad9c8dd6b28bae2a924c95b05976f5252fe4ca584515bdae216d3c98852ae83bb591ca619dd725a24a4acdf708153962
|
7
|
+
data.tar.gz: da9170abf6fbfa984976fcac3c733483a7f3e61fe7e2a0be955a69413bca97c8f1ec2d917506a07ce37d24706219c43fbb234e3ba80fdb8a7b7763842d2ae089
|
data/exe/n_cipher
CHANGED
@@ -8,22 +8,20 @@ class NCipherCLI < Thor
|
|
8
8
|
class_option :seed, :type => :string, :default => 'にゃんぱす'
|
9
9
|
class_option :delimiter, :type => :string, :default => '〜'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
string ||= $stdin.read.chomp
|
14
|
-
STDOUT.puts NCipher::encode(string, seed: options[:seed], delimiter: options[:delimiter])
|
15
|
-
rescue => e
|
16
|
-
STDERR.puts e.message
|
17
|
-
exit 1
|
18
|
-
end
|
11
|
+
sub_commands = {'encode' => ['encode <STRING>', '文字列をN暗号化'],
|
12
|
+
'decode' => ['decode <STRING>', 'N暗号文字列を復号化']}
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
string
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
sub_commands.each_pair do |command, (synopsis, description)|
|
15
|
+
desc(synopsis, description)
|
16
|
+
define_method(command) do |string = nil|
|
17
|
+
begin
|
18
|
+
string ||= $stdin.read.chomp
|
19
|
+
STDOUT.puts NCipher.send(command, string, seed: options[:seed], delimiter: options[:delimiter])
|
20
|
+
rescue => e
|
21
|
+
STDERR.puts "#{__FILE__}: #{e.message}"
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
end
|
27
25
|
end
|
28
26
|
|
29
27
|
desc 'version', 'Print version'
|
data/lib/n_cipher/version.rb
CHANGED
data/lib/n_cipher.rb
CHANGED
@@ -35,9 +35,7 @@ module NCipher
|
|
35
35
|
|
36
36
|
def decode(string, seed: , delimiter: )
|
37
37
|
common_argument_check(string, seed, delimiter)
|
38
|
-
|
39
|
-
raise ArgumentError, "'#{ele}' is not include in the cipher string." unless ele.chars.map {|char| string.include?(char) }.all?
|
40
|
-
end
|
38
|
+
raise ArgumentError, 'Delimiter is not include in the cipher string.' unless delimiter.chars.map {|char| string.include?(char) }.all?
|
41
39
|
raise ArgumentError, 'Invalid cipher string.' unless (string.chars - "#{seed}#{delimiter}".chars).size.zero?
|
42
40
|
|
43
41
|
string.split(delimiter).map {|ele| [ele.gsub(/./, convert_table(seed, :decode)).to_i(seed.size)].pack('U') }.join
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: n_cipher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaya Takeda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|