racoon_encrypt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/Rakefile +10 -0
- data/bin/setup +8 -0
- data/lib/racoon_encrypt/version.rb +4 -0
- data/lib/racoon_encrypt.rb +51 -0
- data/racoon_encrypt.gemspec +27 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 93dd2aa0ff4988783f955303f54df1b6d8a0fcbb
|
4
|
+
data.tar.gz: 11c39e3f5d7b7ce272da4cb8f25894f7d5dd4c11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e8296dba6ded49d392fbe73351af542f82c20f6c42a209a66a0b4f56d079342ab5ddb2e255ce7b32e85781ddba7b570fef6404f0a8b026be227aaf00f3ecc32
|
7
|
+
data.tar.gz: f80fafc402533aacb3e57890da921fecc42a8b686bf7f469f10045f53b95407245ec6cc1aa3639863618f5bf90c61a28c7f7373a728bd242ab7de2aac9629db2
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 as-is-prog
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# RacoonEncrypt
|
2
|
+
|
3
|
+
某実習11回提出課題のために作成された、たぬき暗号の生成、たぬき暗号の復号を行うクラスを提供するRubyGemです。
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'racoon_encrypt'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install racoon_encrypt
|
20
|
+
|
21
|
+
## Usage examples
|
22
|
+
|
23
|
+
###定番
|
24
|
+
```ruby
|
25
|
+
rc_encrypt = RacoonEncrypt.new
|
26
|
+
enc_str = "たなべにたされたるのはかんたべんですた"
|
27
|
+
rc_encrypt.decrypt(enc_str) #=>"なべにされるのはかんべんです"
|
28
|
+
```
|
29
|
+
###貯蓄。お金をたくわえる
|
30
|
+
```ruby
|
31
|
+
rc_encrypt = RacoonEncrypt.new("た")
|
32
|
+
plane_str = "おかね"
|
33
|
+
rc_encrypt.encrypt(plane_str) #example=>"おたかね"
|
34
|
+
```
|
35
|
+
|
36
|
+
###にぬき(※関西方言でゆでたまご)
|
37
|
+
```ruby
|
38
|
+
rc_encrypt = RacoonEncrypt.new("に")
|
39
|
+
enc_str = "ゆにでたにまご"
|
40
|
+
rc_encrypt.decrypt(enc_str) #=>"ゆでたまご"
|
41
|
+
```
|
42
|
+
|
43
|
+
###脱毛
|
44
|
+
```ruby
|
45
|
+
rc_encrypt = RacoonEncrypt.new("け")
|
46
|
+
enc_str = "つけるつけるのけはけだ"
|
47
|
+
rc_encrypt.decrypt(enc_str)#=>"つるつるのはだ"
|
48
|
+
```
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# coding:utf-8
|
2
|
+
require_relative "racoon_encrypt/version"
|
3
|
+
|
4
|
+
# たぬき暗号のクラス
|
5
|
+
# @author as-is-prog
|
6
|
+
# @attr enc_char [String] 暗号化に使う文字
|
7
|
+
class RacoonEncrypt
|
8
|
+
# コンストラクタ
|
9
|
+
# @param [String] enc_char 暗号化に使う文字
|
10
|
+
def initialize(enc_char="た")
|
11
|
+
self.enc_char = enc_char
|
12
|
+
end
|
13
|
+
|
14
|
+
# enc_charのアクセサメソッド
|
15
|
+
# @param enc_char [String] セットしたい暗号化に使う文字
|
16
|
+
# @raise 渡された文字列が一文字でない場合
|
17
|
+
def enc_char=(enc_char)
|
18
|
+
raise "暗号で使う文字は一文字で!" if enc_char.length != 1
|
19
|
+
@enc_char = enc_char
|
20
|
+
end
|
21
|
+
|
22
|
+
# 復号メソッド
|
23
|
+
# @param str [String] 暗号化された文字列
|
24
|
+
# @return [String] 暗号化後の文字列
|
25
|
+
# @example たぬきうどん
|
26
|
+
# racoon_encrypt.decrypt("たうたどたん") #=>"うどん"
|
27
|
+
def decrypt(str)
|
28
|
+
regex = Regexp.compile(@enc_char)
|
29
|
+
str.gsub(regex,'')
|
30
|
+
end
|
31
|
+
|
32
|
+
# 暗号化メソッド
|
33
|
+
# @param str [String] 暗号化したい文字列
|
34
|
+
# @return [String] 複合された文字列
|
35
|
+
# @raise 既にenc_charが文字列に含まれている場合
|
36
|
+
# @example 貯蓄は大事。お金はたくわえたい。
|
37
|
+
# racoon_encrypt.decrypt("おかね") #=> ランダムにたくわえられた文字列
|
38
|
+
def encrypt(str)
|
39
|
+
raise "文字列に既に[#{@enc_char}]が含まれています!" if str.include?(@enc_char)
|
40
|
+
ta_count = str.length * 2 / 3
|
41
|
+
ta_array = (@enc_char*ta_count).split("")
|
42
|
+
(str.length - ta_count).times{ta_array << ""}
|
43
|
+
ta_array.shuffle!
|
44
|
+
|
45
|
+
retstr = ""
|
46
|
+
str.length.times do |i|
|
47
|
+
retstr << (ta_array[i] + str[i])
|
48
|
+
end
|
49
|
+
retstr
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'racoon_encrypt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "racoon_encrypt"
|
8
|
+
spec.version = RacoonEncrypt::VERSION
|
9
|
+
spec.authors = ["as-is-prog"]
|
10
|
+
spec.email = ["as-is-prog@outlook.jp"]
|
11
|
+
|
12
|
+
spec.summary = "某実習で作成した、たぬき暗号を生成するgem"
|
13
|
+
spec.description = "たぬき暗号化及び、たぬき暗号の復号を行えるクラスを提供します。"
|
14
|
+
spec.homepage = "http://rubygems.org/gems/racoon_encrypt"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: racoon_encrypt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- as-is-prog
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: たぬき暗号化及び、たぬき暗号の復号を行えるクラスを提供します。
|
56
|
+
email:
|
57
|
+
- as-is-prog@outlook.jp
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/setup
|
69
|
+
- lib/racoon_encrypt.rb
|
70
|
+
- lib/racoon_encrypt/version.rb
|
71
|
+
- racoon_encrypt.gemspec
|
72
|
+
homepage: http://rubygems.org/gems/racoon_encrypt
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.5.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: 某実習で作成した、たぬき暗号を生成するgem
|
96
|
+
test_files: []
|