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 +4 -4
- data/README.rdoc +1 -1
- data/lib/yaml_zlib_blowfish.rb +40 -3
- metadata +4 -6
- data/lib/yaml_zlib_blowfish/version.rb +0 -3
- data/lib/yaml_zlib_blowfish/yaml_zlib_blowfish.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8140c9848f3b27b2853fade488e4d6e13f8670d0
|
4
|
+
data.tar.gz: a8bda76cf67c032024b68fcad8f3ffb43eeff8d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60b8ab466fac3b10dc52b09e07cd7ba895eb0215da6307545151c9663332566045cebd1c70a4028c4a399e6fdb1c1887887009c5d98f9a32fc2a806d40840c5
|
7
|
+
data.tar.gz: dc4dbbc62745c59b7b8464d0ea7d9a9925e0b8380d65f2b17aed3072bbc99f65d1449854112116087145f1aacb0c21351a1dcbe4aa268c0f37ac69c373f64c01
|
data/README.rdoc
CHANGED
data/lib/yaml_zlib_blowfish.rb
CHANGED
@@ -4,9 +4,46 @@ require 'zlib'
|
|
4
4
|
require 'openssl'
|
5
5
|
require 'digest/sha2'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
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:
|
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.
|
45
|
+
- 'ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]'
|
48
46
|
rubyforge_project:
|
49
|
-
rubygems_version: 2.
|
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,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
|