parol 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/parol.rb +1 -0
- data/lib/parol/database.rb +80 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 196bbaa89b2f83e4867c090b654525b08936a1e9
|
4
|
+
data.tar.gz: 2d771ef0055adf38c422ebe6ec384fdaef6542c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0777384f3012c2a9550388fc6d1b63323e99eb5ea5357388f08203ecf616ad90731d0651bdf00a8fe0612af077c567f0daf9863d5d56f39b954cada68e2845f
|
7
|
+
data.tar.gz: d343c9ae47f70ad1716083697568c2f7bb41e2e4a209bf5f2dee394da0f1662dcbc47125b52025dab040223b5b2a41492ed4bf3f507f945dd97b1a258abdf962
|
data/lib/parol.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'parol/database'
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rbnacl/libsodium'
|
2
|
+
|
3
|
+
module Parol
|
4
|
+
|
5
|
+
class ParolError < StandardError; end
|
6
|
+
class BadPasswordLength < ParolError; end
|
7
|
+
class DecryptionFailed < ParolError; end # wrong password or wrong file
|
8
|
+
|
9
|
+
class Database
|
10
|
+
|
11
|
+
def initialize database, password
|
12
|
+
@database = database
|
13
|
+
@password = password
|
14
|
+
|
15
|
+
@binary_password = String.new @password, encoding: 'BINARY'
|
16
|
+
@box = RbNaCl::SimpleBox.from_secret_key @binary_password
|
17
|
+
|
18
|
+
rescue RbNaCl::LengthError
|
19
|
+
raise BadPasswordLength
|
20
|
+
end
|
21
|
+
|
22
|
+
def add program, login, password, notes
|
23
|
+
data = decrypt
|
24
|
+
|
25
|
+
data << {
|
26
|
+
program: program,
|
27
|
+
login: login,
|
28
|
+
password: password,
|
29
|
+
notes: notes
|
30
|
+
}
|
31
|
+
|
32
|
+
encrypt data
|
33
|
+
end
|
34
|
+
|
35
|
+
def accounts &block
|
36
|
+
data = decrypt
|
37
|
+
|
38
|
+
if block_given?
|
39
|
+
data.each do |h|
|
40
|
+
yield h
|
41
|
+
end
|
42
|
+
else
|
43
|
+
data
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def save data
|
48
|
+
encrypt data
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def decrypt
|
53
|
+
unless File.exist? @database
|
54
|
+
create
|
55
|
+
end
|
56
|
+
|
57
|
+
data = File.binread @database
|
58
|
+
Marshal.load @box.decrypt(data)
|
59
|
+
|
60
|
+
rescue RbNaCl::CryptoError
|
61
|
+
raise DecryptionFailed
|
62
|
+
end
|
63
|
+
|
64
|
+
def encrypt data
|
65
|
+
File.open @database, 'wb' do |file|
|
66
|
+
dump = Marshal.dump data
|
67
|
+
file.write @box.encrypt dump
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def create
|
72
|
+
File.open @database, 'wb' do |file|
|
73
|
+
dump = Marshal.dump Array.new
|
74
|
+
file.write @box.encrypt(dump)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: parol
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.5.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ogromny
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rbnacl-libsodium
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.11
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.11
|
33
|
+
description: A secure password manager
|
34
|
+
email: ogromny@openmailbox.org
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/parol.rb
|
40
|
+
- lib/parol/database.rb
|
41
|
+
homepage: https://github.com/Ogromny/parol/
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.6.8
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: parol
|
65
|
+
test_files: []
|