yaml_zlib_blowfish 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26513d0afc58b0430f20cf9f12d06f15107dd0c8
4
+ data.tar.gz: aa2ddf4d1eef0c41f021c1b65092aac05e3b4ff5
5
+ SHA512:
6
+ metadata.gz: 1e7d35cdb82bbfd5587bc607d7e06eeaba749d6e90f5b4f2c78a63067f632e06538daa7c50b05fef526cbdee67a63ae3574b43e00919482c44a327b9dc3fe631
7
+ data.tar.gz: 43711ed63a6fb26419c726d1e316e5a712bf13fa3d1a08c447c63b799636d42932a992251e0c819291727e2700ac8a543d318fd8ede7271168c1ea2a481b5552
data/README.rdoc ADDED
@@ -0,0 +1,46 @@
1
+ = yaml_zlib_blowfish
2
+
3
+ {<img src="https://badge.fury.io/rb/gtk3app.svg" alt="Gem Version" />}[http://badge.fury.io/rb/gtk3app]
4
+
5
+ == DESCRIPTION:
6
+
7
+ Have you ever wanted to YAML dump, Zlib compress, and Blowfish encrypt your data structures?
8
+ YOU HAVE!? Well...
9
+
10
+ == SYNOPSIS:
11
+
12
+ require 'yaml_zlib_blowfish'
13
+ # ...
14
+ yzb = YamlZlibBlowfish.new('passphrase')
15
+ data = yzb.load('./path_to/file.yzb')
16
+ # ...
17
+ yzb.dump('./path_to/file.yzb', data)
18
+
19
+ == INSTALL:
20
+
21
+ $ sudo gem install yaml_zlib_blowfish
22
+
23
+ == LICENSE:
24
+
25
+ (The MIT License)
26
+
27
+ Copyright (c) 2014 carlosjhr64
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining
30
+ a copy of this software and associated documentation files (the
31
+ 'Software'), to deal in the Software without restriction, including
32
+ without limitation the rights to use, copy, modify, merge, publish,
33
+ distribute, sublicense, and/or sell copies of the Software, and to
34
+ permit persons to whom the Software is furnished to do so, subject to
35
+ the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be
38
+ included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
41
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
44
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
45
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
46
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ # Standard Libraries
2
+ require 'yaml'
3
+ require 'zlib'
4
+ require 'openssl'
5
+ require 'digest/sha2'
6
+
7
+ # This Gem
8
+ require 'yaml_zlib_blowfish/version.rb'
9
+ require 'yaml_zlib_blowfish/yaml_zlib_blowfish.rb'
10
+
11
+ # Requires:
12
+ #`ruby`
@@ -0,0 +1,3 @@
1
+ class YamlZlibBlowfish
2
+ VERSION = '0.0.0'
3
+ end
@@ -0,0 +1,41 @@
1
+ YAML::ENGINE.yamler = 'psych'
2
+
3
+ class YamlZlibBlowfish
4
+
5
+ # cypher_key = yzb.key
6
+ attr_accessor :key
7
+
8
+ # yzb = YamlZlibBlowfish.new(passphrase)
9
+ def initialize(passphrase)
10
+ @key = Digest::SHA256.digest(passphrase)
11
+ end
12
+
13
+ # encrypted_string = yzb.cipher(:encrypt, plain_string)
14
+ # plain_string = yzb.cipher(:decrypt, encrypted_string)
15
+ def cipher(mode, data)
16
+ cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').send(mode)
17
+ cipher.key = @key
18
+ cipher.update(data) << cipher.final
19
+ end
20
+
21
+ # plain_structure = yzb.decrypt(encrypted_compressed_dump)
22
+ def decrypt(encrypted)
23
+ YAML.load(Zlib::Inflate.inflate(cipher(:decrypt, encrypted)))
24
+ end
25
+
26
+ # encrypted_compressed_dump = yzb.encrypt(plain_structure)
27
+ def encrypt(plain)
28
+ cipher(:encrypt, Zlib::Deflate.deflate(YAML.dump(plain)))
29
+ end
30
+
31
+ # plain_structure = yzb.load(filename)
32
+ def load(dumpfile)
33
+ decrypt(File.read(dumpfile))
34
+ end
35
+
36
+ # yzb.dump(filename, plain_structure)
37
+ def dump(dumpfile, data)
38
+ File.write(dumpfile, encrypt(data))
39
+ end
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yaml_zlib_blowfish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - carlosjhr64
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ Have you ever wanted to YAML dump, Zlib compress, and Blowfish encrypt your data structures?
15
+ YOU HAVE!? Well...
16
+ email: carlosjhr64@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files:
20
+ - README.rdoc
21
+ files:
22
+ - README.rdoc
23
+ - lib/yaml_zlib_blowfish.rb
24
+ - lib/yaml_zlib_blowfish/version.rb
25
+ - lib/yaml_zlib_blowfish/yaml_zlib_blowfish.rb
26
+ homepage: https://github.com/carlosjhr64/yaml_zlib_blowfish
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options:
32
+ - "--main"
33
+ - README.rdoc
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements:
47
+ - 'ruby: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]'
48
+ rubyforge_project:
49
+ rubygems_version: 2.4.1
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Have you ever wanted to YAML dump, Zlib compress, and Blowfish encrypt your
53
+ data structures? YOU HAVE!? Well...
54
+ test_files: []
55
+ has_rdoc: