yaml_zlib_blowfish 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5065d47b908479c5d72874a03551965258ece16f
4
- data.tar.gz: 24db8001caee6c7906aacc7a5a8c644c927f1f4b
3
+ metadata.gz: 8140c9848f3b27b2853fade488e4d6e13f8670d0
4
+ data.tar.gz: a8bda76cf67c032024b68fcad8f3ffb43eeff8d0
5
5
  SHA512:
6
- metadata.gz: 4ccde6d2ed05550cb00ecf56ed956bc9c534aa4683fd54d8eed3627e0dd121887f862cf80c0e6a640c45afc293ccec95e13fc93407379b3008ea4c91592a5e21
7
- data.tar.gz: 03bde41c5549772bbe4dd6756aa4bea9228e3a7b917742689cc20493dfbd2a721c0e0b60a3c7cd1d14ddb33c3312654dcb4103c18141097ccc9644d497858134
6
+ metadata.gz: e60b8ab466fac3b10dc52b09e07cd7ba895eb0215da6307545151c9663332566045cebd1c70a4028c4a399e6fdb1c1887887009c5d98f9a32fc2a806d40840c5
7
+ data.tar.gz: dc4dbbc62745c59b7b8464d0ea7d9a9925e0b8380d65f2b17aed3072bbc99f65d1449854112116087145f1aacb0c21351a1dcbe4aa268c0f37ac69c373f64c01
@@ -24,7 +24,7 @@ YOU HAVE!? Well...
24
24
 
25
25
  (The MIT License)
26
26
 
27
- Copyright (c) 2014 carlosjhr64
27
+ Copyright (c) 2017 carlosjhr64
28
28
 
29
29
  Permission is hereby granted, free of charge, to any person obtaining
30
30
  a copy of this software and associated documentation files (the
@@ -4,9 +4,46 @@ require 'zlib'
4
4
  require 'openssl'
5
5
  require 'digest/sha2'
6
6
 
7
- # This Gem
8
- require 'yaml_zlib_blowfish/version.rb'
9
- require 'yaml_zlib_blowfish/yaml_zlib_blowfish.rb'
7
+ class YamlZlibBlowfish
8
+ VERSION = '0.1.0'
9
+
10
+ # cypher_key = yzb.key
11
+ attr_accessor :key
12
+
13
+ # yzb = YamlZlibBlowfish.new(passphrase)
14
+ def initialize(passphrase)
15
+ @key = Digest::SHA256.digest(passphrase)[0..15]
16
+ end
17
+
18
+ # encrypted_string = yzb.cipher(:encrypt, plain_string)
19
+ # plain_string = yzb.cipher(:decrypt, encrypted_string)
20
+ def cipher(mode, data)
21
+ #cipher = OpenSSL::Cipher.new('bf-cbc').send(mode)
22
+ cipher = OpenSSL::Cipher::BF.new(:CBC).send(mode)
23
+ cipher.key = @key
24
+ cipher.update(data) << cipher.final
25
+ end
26
+
27
+ # plain_structure = yzb.decrypt(encrypted_compressed_dump)
28
+ def decrypt(encrypted)
29
+ YAML.load(Zlib::Inflate.inflate(cipher(:decrypt, encrypted)))
30
+ end
31
+
32
+ # encrypted_compressed_dump = yzb.encrypt(plain_structure)
33
+ def encrypt(plain)
34
+ cipher(:encrypt, Zlib::Deflate.deflate(YAML.dump(plain)))
35
+ end
36
+
37
+ # plain_structure = yzb.load(filename)
38
+ def load(dumpfile)
39
+ decrypt(File.read(dumpfile))
40
+ end
41
+
42
+ # yzb.dump(filename, plain_structure)
43
+ def dump(dumpfile, data)
44
+ File.write(dumpfile, encrypt(data))
45
+ end
46
+ end
10
47
 
11
48
  # Requires:
12
49
  #`ruby`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_zlib_blowfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-13 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Have you ever wanted to YAML dump, Zlib compress, and Blowfish encrypt your data structures?
@@ -21,8 +21,6 @@ extra_rdoc_files:
21
21
  files:
22
22
  - README.rdoc
23
23
  - lib/yaml_zlib_blowfish.rb
24
- - lib/yaml_zlib_blowfish/version.rb
25
- - lib/yaml_zlib_blowfish/yaml_zlib_blowfish.rb
26
24
  homepage: https://github.com/carlosjhr64/yaml_zlib_blowfish
27
25
  licenses:
28
26
  - MIT
@@ -44,9 +42,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
42
  - !ruby/object:Gem::Version
45
43
  version: '0'
46
44
  requirements:
47
- - 'ruby: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]'
45
+ - 'ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]'
48
46
  rubyforge_project:
49
- rubygems_version: 2.4.5
47
+ rubygems_version: 2.6.11
50
48
  signing_key:
51
49
  specification_version: 4
52
50
  summary: Have you ever wanted to YAML dump, Zlib compress, and Blowfish encrypt your
@@ -1,3 +0,0 @@
1
- class YamlZlibBlowfish
2
- VERSION = '0.0.1'
3
- end
@@ -1,39 +0,0 @@
1
- class YamlZlibBlowfish
2
-
3
- # cypher_key = yzb.key
4
- attr_accessor :key
5
-
6
- # yzb = YamlZlibBlowfish.new(passphrase)
7
- def initialize(passphrase)
8
- @key = Digest::SHA256.digest(passphrase)
9
- end
10
-
11
- # encrypted_string = yzb.cipher(:encrypt, plain_string)
12
- # plain_string = yzb.cipher(:decrypt, encrypted_string)
13
- def cipher(mode, data)
14
- cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').send(mode)
15
- cipher.key = @key
16
- cipher.update(data) << cipher.final
17
- end
18
-
19
- # plain_structure = yzb.decrypt(encrypted_compressed_dump)
20
- def decrypt(encrypted)
21
- YAML.load(Zlib::Inflate.inflate(cipher(:decrypt, encrypted)))
22
- end
23
-
24
- # encrypted_compressed_dump = yzb.encrypt(plain_structure)
25
- def encrypt(plain)
26
- cipher(:encrypt, Zlib::Deflate.deflate(YAML.dump(plain)))
27
- end
28
-
29
- # plain_structure = yzb.load(filename)
30
- def load(dumpfile)
31
- decrypt(File.read(dumpfile))
32
- end
33
-
34
- # yzb.dump(filename, plain_structure)
35
- def dump(dumpfile, data)
36
- File.write(dumpfile, encrypt(data))
37
- end
38
-
39
- end