ossl_cryptor 0.4.1 → 0.5.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 +4 -4
- data/README.md +8 -7
- data/lib/ossl_cryptor.rb +5 -3
- data/lib/ossl_cryptor/cryptor.rb +2 -2
- data/lib/ossl_cryptor/version.rb +1 -1
- data/ossl_cryptor.gemspec +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 135322ac878aa9b4cbc3d264fb6377c992e9c489
|
4
|
+
data.tar.gz: 4458f3e9b55d6e3633922111b89db46701d7904c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1265fff1d655a00d679a8022c5e39f203a2c9b7133cca0004eeb91cf780e913d779ae9ea790c051895109977b97be61b0db466e683a1146bf9df808fd48441
|
7
|
+
data.tar.gz: cea75a04357fcbb1c333d5e2ea67b0a9c12ef7128353950cbaa7ac18559e3a5accdf0e098cbcd95c656bb259d026fcd1ab1ea002effc144a6dd38c74463adeb1
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ossl_cryptor`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
This gem provide crypt process by DES and AES-256-CBC.
|
5
|
+
This gem provide crypt process by DES and AES-128-CBC, AES-256-CBC.
|
6
6
|
Use openssl lib.
|
7
7
|
|
8
8
|
## Installation
|
@@ -24,18 +24,19 @@ Or install it yourself as:
|
|
24
24
|
## Usage
|
25
25
|
|
26
26
|
You implement the method of the AES-256-CBC as a sample.
|
27
|
-
DES can also be run in the same way (only the specified mode is different).
|
27
|
+
AES-128-CBC and DES can also be run in the same way (only the specified mode is different).
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
gem 'ossl_cryptor'
|
31
31
|
|
32
|
-
cryptor
|
32
|
+
# Create AES-256-CBC cryptor instance.
|
33
|
+
cryptor = OsslCryptor::Cryptor.new(OsslCryptor::AES_256)
|
33
34
|
|
34
|
-
#
|
35
|
-
enc_value = cryptor.encrypt("
|
35
|
+
# Encrypt
|
36
|
+
enc_value = cryptor.encrypt("encrypt target value.")
|
36
37
|
p enc_value
|
37
38
|
|
38
|
-
#
|
39
|
+
# Decrypt
|
39
40
|
dec_value = cryptor.decrypt(enc_value)
|
40
41
|
p dec_value
|
41
42
|
```
|
@@ -48,7 +49,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
48
49
|
|
49
50
|
## Contributing
|
50
51
|
|
51
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/koyupi/ossl_cryptor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
52
53
|
|
53
54
|
|
54
55
|
## License
|
data/lib/ossl_cryptor.rb
CHANGED
@@ -9,8 +9,10 @@ module OsslCryptor
|
|
9
9
|
|
10
10
|
# DES Mode.
|
11
11
|
DES = "DES"
|
12
|
-
# AES Mode.
|
13
|
-
|
12
|
+
# AES-128-CBC Mode.
|
13
|
+
AES_128 = "AES-128-CBC"
|
14
|
+
# AES-256-CBC Mode.
|
15
|
+
AES_256 = "AES-256-CBC"
|
14
16
|
|
15
17
|
# RFC2045
|
16
18
|
RFC2045 = 0
|
@@ -19,6 +21,6 @@ module OsslCryptor
|
|
19
21
|
|
20
22
|
# @return [String] availabe cipher.
|
21
23
|
def self.available
|
22
|
-
"#{
|
24
|
+
"#{AES_128}, #{AES_256}, #{DES}"
|
23
25
|
end
|
24
26
|
end
|
data/lib/ossl_cryptor/cryptor.rb
CHANGED
@@ -17,7 +17,7 @@ module OsslCryptor
|
|
17
17
|
def initialize(mode, key_iv=nil, pass=nil, salt=nil, key_iv_hash=nil)
|
18
18
|
|
19
19
|
# if invalid mode, raise error.
|
20
|
-
if (
|
20
|
+
if (AES_128 != mode) && (AES_256 != mode) && (DES != mode)
|
21
21
|
raise OpenSSL::Cipher::CipherError.new("invalid mode : #{mode}")
|
22
22
|
end
|
23
23
|
|
@@ -154,7 +154,7 @@ module OsslCryptor
|
|
154
154
|
|
155
155
|
default_salt = nil
|
156
156
|
|
157
|
-
if mode ==
|
157
|
+
if (mode == AES_128) || (mode == AES_256)
|
158
158
|
default_salt = OpenSSL::Random.random_bytes(8)
|
159
159
|
elsif mode == DES
|
160
160
|
default_salt = OpenSSL::Random.random_bytes(2)
|
data/lib/ossl_cryptor/version.rb
CHANGED
data/ossl_cryptor.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["h.shigemoto"]
|
10
10
|
spec.email = ["corporation.ore@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{This gem provide crypt by AES-256-CBC and DES.}
|
13
|
-
spec.description = %q{This gem provide crypt by AES-256-CBC and DES. Use openssl lib.}
|
14
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.summary = %q{This gem provide crypt by AES-128-CBC, AES-256-CBC and DES.}
|
13
|
+
spec.description = %q{This gem provide crypt by AES-128-CBC, AES-256-CBC and DES. Use openssl lib.}
|
14
|
+
spec.homepage = "https://github.com/koyupi/ossl_cryptor"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ossl_cryptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- h.shigemoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: This gem provide crypt by AES-256-CBC and DES. Use openssl
|
55
|
+
description: This gem provide crypt by AES-128-CBC, AES-256-CBC and DES. Use openssl
|
56
|
+
lib.
|
56
57
|
email:
|
57
58
|
- corporation.ore@gmail.com
|
58
59
|
executables: []
|
@@ -74,7 +75,7 @@ files:
|
|
74
75
|
- lib/ossl_cryptor/generator.rb
|
75
76
|
- lib/ossl_cryptor/version.rb
|
76
77
|
- ossl_cryptor.gemspec
|
77
|
-
homepage: https://github.com/
|
78
|
+
homepage: https://github.com/koyupi/ossl_cryptor
|
78
79
|
licenses:
|
79
80
|
- MIT
|
80
81
|
metadata: {}
|
@@ -94,9 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.6.
|
98
|
+
rubygems_version: 2.6.6
|
98
99
|
signing_key:
|
99
100
|
specification_version: 4
|
100
|
-
summary: This gem provide crypt by AES-256-CBC and DES.
|
101
|
+
summary: This gem provide crypt by AES-128-CBC, AES-256-CBC and DES.
|
101
102
|
test_files: []
|
102
|
-
has_rdoc:
|