crypt-api 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8ee36a144a18c50dc6105dc08880208f69f53e3
4
+ data.tar.gz: 64319210f733d382f30b5d8c8d5d53964904afb6
5
+ SHA512:
6
+ metadata.gz: edac270899560d21e091c31735f8dd51eddc010003fb2d945c9bf0599232aa910bf6c32a9822abee4a0320fab510a31eb8bbdb04a5a7db86facceab9198d2f22
7
+ data.tar.gz: bde9ad422985a408409bbe3eb72c8ff9f06703a22e377d6b67afd7b35756668f2db24e04f176332a561f18423fc716c5e7bfadf806e3cf242fc38e6c5563bded
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bitcode_api.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Alexey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # CryptApi
2
+
3
+ The gem sending an encrypted request to the specified address and decrypting of the received response. Demo-version 0.0.1.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'crypt_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install crypt-api
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ include CryptApi
25
+ ```
26
+
27
+ ```ruby
28
+ CryptApi::Main.send_encrypted_request(YOUR_URL_HERE , data: {param_1: "param1", param_2: "param2" })
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/alexmatskevich/crypt_api/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitcode_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "crypt-api"
8
+ spec.version = BitcodeApi::VERSION
9
+ spec.authors = ["Alexey"]
10
+ spec.email = ["41exmackevich@gmail.com"]
11
+ spec.summary = %q{Api}
12
+ spec.description = %q{The gem sending an encrypted request to the specified address and decrypting of the received response.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,53 @@
1
+ require "bitcode_api/version"
2
+ require "net/http"
3
+ require 'openssl'
4
+
5
+
6
+ module CryptApi
7
+
8
+ class Sender
9
+
10
+ def initialize(url)
11
+ @url = url
12
+ end
13
+
14
+ def post_data(data)
15
+ uri = URI(@url)
16
+ response = Net::HTTP.post_form(uri, data)
17
+ response.body
18
+ end
19
+
20
+ end
21
+
22
+ class EncryptFactory
23
+
24
+ def encrypt(data)
25
+ cipher = OpenSSL::Cipher::AES.new(128, :CBC)
26
+ cipher.encrypt
27
+ key = cipher.random_key
28
+ iv = cipher.random_iv
29
+
30
+ cipher.update(data) + cipher.final
31
+ end
32
+
33
+ def decrypt
34
+ decipher = OpenSSL::Cipher::AES.new(128, :CBC)
35
+ decipher.decrypt
36
+ decipher.key = key
37
+ decipher.iv = iv
38
+
39
+ decipher.update(encrypted) + decipher.final
40
+ end
41
+
42
+ end
43
+
44
+
45
+ class Main
46
+ def self.send_encrypted_request(url ,data)
47
+ encrypted_data = EncryptFactory.new.encrypt(data.to_s)
48
+ Sender.new(url).post_data(data: encrypted_data)
49
+ end
50
+ end
51
+
52
+
53
+ end
@@ -0,0 +1,3 @@
1
+ module BitcodeApi
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crypt-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Alexey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-21 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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
+ description: The gem sending an encrypted request to the specified address and decrypting
42
+ of the received response.
43
+ email:
44
+ - 41exmackevich@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bitcode_api.gemspec
55
+ - lib/bitcode_api.rb
56
+ - lib/bitcode_api/version.rb
57
+ homepage: ''
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.4.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Api
81
+ test_files: []