lolitado 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/box.rb +29 -0
  3. data/lib/lolitado.rb +1 -0
  4. data/lib/version.rb +1 -1
  5. metadata +16 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1b994f8ee23ddb68c0538490bd5b18e9e3c08b27aa37ff3a561044d79751cb9
4
- data.tar.gz: 96d4aab3e4c3f091d59e69b87a956b5c3f4a602db41ba5b49220cc03445ba756
3
+ metadata.gz: f4593b789441691af7ce5209e43bd8c892773802a90b07d1b70e52be69623bd0
4
+ data.tar.gz: 6a79033590439dc2e0df53f54fc21bcf06d997ce970a1c1614fbce565a6f76b0
5
5
  SHA512:
6
- metadata.gz: 3f692b16a95e32587e4f4194fcd379afc72fc5c07dacf72a353df02887af16c387a808b54b1828bc5710eb2c8708b761f2b2ec1201b6c956aada662c1a889a2f
7
- data.tar.gz: 2ccb705cf3f67d1828b386d0667b9d9080fdb8523881ae8ad190c5aeb8b2336f4f61b4c7ede69cd310303183d8fabe9fdaaac21c3989b3c6a3910ddfe6dc98da
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
@@ -1,6 +1,7 @@
1
1
  require 'pool'
2
2
  require 'db'
3
3
  require 'request'
4
+ require 'box'
4
5
 
5
6
  module LolitaDo
6
7
  class LolitaClass
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lolitado
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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.5
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