lolitado 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/box.rb +29 -0
- data/lib/lolitado.rb +1 -0
- data/lib/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4593b789441691af7ce5209e43bd8c892773802a90b07d1b70e52be69623bd0
|
4
|
+
data.tar.gz: 6a79033590439dc2e0df53f54fc21bcf06d997ce970a1c1614fbce565a6f76b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ef37176d0bc93d3752b841bcca7c74d5ad8d06597e9c095ff1d717829d52abf4b2a10db53c6144bc17cd18824ed9f99ba04575c0c345619e59461d64a90d99f
|
7
|
+
data.tar.gz: d91138239f330ec6d3c1f0755ba67b0f52e4adbd14b95da7843d74492555bd35c6f86384a8494fe2fee645352d4fc30a94cfc9de727d6744d035d50c9ed3d07a
|
data/lib/box.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rbnacl'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
class Box
|
5
|
+
|
6
|
+
def initialize key
|
7
|
+
key_env = ENV[key]
|
8
|
+
if key_env.nil?
|
9
|
+
puts "There's no environment variable #{key}..."
|
10
|
+
return
|
11
|
+
end
|
12
|
+
key = Base64.decode64(key_env)
|
13
|
+
@box = RbNaCl::SimpleBox.from_secret_key(key)
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_encrypt file
|
17
|
+
plaintext = File.read(file)
|
18
|
+
ciphertext = @box.encrypt(plaintext)
|
19
|
+
enc_file = file + '.enc'
|
20
|
+
File.write(enc_file, Base64.encode64(ciphertext))
|
21
|
+
end
|
22
|
+
|
23
|
+
def file_decrypt file
|
24
|
+
ciphertext = File.read(file)
|
25
|
+
plaintext = @box.decrypt(Base64.decode64(ciphertext))
|
26
|
+
plain_file = file[0..-5]
|
27
|
+
File.write(plain_file, plaintext)
|
28
|
+
end
|
29
|
+
end
|
data/lib/lolitado.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolitado
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dolores Zhang
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rbnacl-libsodium
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.10
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.10
|
69
83
|
description: Lolitado DSL that works with Watir
|
70
84
|
email:
|
71
85
|
- 379808610@qq.com
|
@@ -74,6 +88,7 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- lib/accessors.rb
|
91
|
+
- lib/box.rb
|
77
92
|
- lib/db.rb
|
78
93
|
- lib/lolitado.rb
|
79
94
|
- lib/pool.rb
|