onnistuu_fi 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/bin/setup +0 -1
- data/lib/onnistuu_fi/form.rb +1 -0
- data/lib/onnistuu_fi/signer.rb +23 -18
- data/lib/onnistuu_fi/version.rb +1 -1
- data/onnistuu_fi.gemspec +1 -2
- metadata +5 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e2d47ad652d33ffa6f0cf337649740357d36d2a
|
4
|
+
data.tar.gz: a4cd132595c28603f3239d3feba4193a1b8f12f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea37983e3b854b88474c52e3ae50a2949dbd7d2cad1beb8c8ee35f9152218d5781ac3e293e0cbc6a7a0846d09450b8a0fd5c68992c8f6597bc46dc5c04c971a
|
7
|
+
data.tar.gz: 0d89a6fe38dd27566c021c28d22608d1f5461308f2d3382502833055298550007a88d9a47402eb3a939988a516107a84e22d5c2d3f4ca86e4de9df326b864a92
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Dependencies
|
22
22
|
|
23
|
-
|
23
|
+
None.
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
@@ -81,3 +81,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
81
81
|
|
82
82
|
Bug reports and pull requests are welcome on GitHub at https://github.com/kiskolabs/onnistuu_fi.
|
83
83
|
|
84
|
+
## License
|
85
|
+
|
86
|
+
The library is released under the MIT License.
|
data/bin/setup
CHANGED
data/lib/onnistuu_fi/form.rb
CHANGED
data/lib/onnistuu_fi/signer.rb
CHANGED
@@ -1,31 +1,36 @@
|
|
1
|
-
require "mcrypt"
|
2
1
|
require "base64"
|
3
2
|
require "openssl"
|
4
3
|
|
5
4
|
module OnnistuuFi
|
6
5
|
class Signer
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
attr_accessor :key
|
7
|
+
|
8
|
+
def initialize(_key, keycode)
|
9
|
+
self.key = Base64.decode64(keycode)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
iv = OpenSSL::Cipher::Cipher.new("AES-256-CBC").random_iv.unpack("H*").first
|
15
|
-
mcrypt = Mcrypt.new(:rijndael_256, :cbc, @encryption_key, iv, :pkcs)
|
12
|
+
def encrypt(message)
|
13
|
+
return nil if message.nil?
|
16
14
|
|
17
|
-
|
15
|
+
iv = OpenSSL::Cipher::Cipher.new("AES-128-CBC").random_iv
|
16
|
+
aes = OpenSSL::Cipher.new('AES-256-CBC')
|
17
|
+
aes.encrypt
|
18
|
+
aes.key = key
|
19
|
+
aes.iv = iv
|
20
|
+
encrypted_data = aes.update(JSON.dump(message)) + aes.final
|
21
|
+
[Base64.encode64(iv), Base64.encode64(encrypted_data)]
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
def decrypt(encrypted_data, iv)
|
25
|
+
return nil if encrypted_data.nil?
|
26
|
+
encrypted_data = Base64.decode64(encrypted_data).strip
|
27
|
+
iv = Base64.decode64(iv).strip
|
28
|
+
aes = OpenSSL::Cipher.new('AES-256-CBC')
|
29
|
+
aes.decrypt
|
30
|
+
aes.key = key
|
31
|
+
aes.iv = iv
|
32
|
+
message = (aes.update(encrypted_data) + aes.final)
|
33
|
+
JSON.load(message)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/lib/onnistuu_fi/version.rb
CHANGED
data/onnistuu_fi.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{Implements Onnistuu.fi interface.}
|
13
13
|
spec.description = %q{Implements Onnistuu.fi interface}
|
14
14
|
spec.homepage = "https://github.com/kiskolabs/onnistuu_fi"
|
15
|
+
spec.licenses = ["MIT"]
|
15
16
|
|
16
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -31,6 +32,4 @@ Gem::Specification.new do |spec|
|
|
31
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
33
|
spec.add_development_dependency "rspec-html-matchers", "~> 0.8.0"
|
33
34
|
spec.add_development_dependency "byebug"
|
34
|
-
spec.add_dependency "aes", "~> 0.5.0"
|
35
|
-
spec.add_dependency "ruby-mcrypt", "~> 0.2.0"
|
36
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onnistuu_fi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vesa Vänskä
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,34 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: aes
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.0
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.5.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: ruby-mcrypt
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.2.0
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.2.0
|
111
83
|
description: Implements Onnistuu.fi interface
|
112
84
|
email:
|
113
85
|
- vesa@vesavanska.com
|
@@ -130,7 +102,8 @@ files:
|
|
130
102
|
- lib/onnistuu_fi/version.rb
|
131
103
|
- onnistuu_fi.gemspec
|
132
104
|
homepage: https://github.com/kiskolabs/onnistuu_fi
|
133
|
-
licenses:
|
105
|
+
licenses:
|
106
|
+
- MIT
|
134
107
|
metadata:
|
135
108
|
allowed_push_host: https://rubygems.org
|
136
109
|
post_install_message:
|
@@ -149,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
122
|
version: '0'
|
150
123
|
requirements: []
|
151
124
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.6.8
|
153
126
|
signing_key:
|
154
127
|
specification_version: 4
|
155
128
|
summary: Implements Onnistuu.fi interface.
|