basic-password 0.1.0
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/basic-password.rb +31 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 711eb6becbd2e5c49fd899dd78bf9ffee8633bb6d7c6a794d7c2d23d5bf3adbd
|
4
|
+
data.tar.gz: 887e87c7119872252a55cb26fcad2c42f2fb7dd40148efe4e8b634ecb1d0d57e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49fa1e651472ffdd6436156b42a9681529331a4c84aa38955cd3320bdb2fe601eb195ce973f837edf272f90b312340103773f8c9dc7c4d73d2f7eb96eb1c6693
|
7
|
+
data.tar.gz: 8861c46a894d8c881b010f705c621c994c8993e163e9514bd48bd58f5146ea751ad3e91a86ad09e946d039c7c9305e5f7e04111342c77aa376915818e752a452
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class BasicPassword
|
5
|
+
attr_reader :salt, :hash
|
6
|
+
|
7
|
+
def initialize(value, salt = SecureRandom.base64)
|
8
|
+
@salt = salt
|
9
|
+
@hash = Digest::SHA2.new(512).hexdigest(value + salt)
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{ salt: @salt, hash: @hash }
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_json
|
17
|
+
JSON.generate to_h
|
18
|
+
end
|
19
|
+
|
20
|
+
def check(value)
|
21
|
+
hash == SecurePassword.new(value, salt).hash
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.digest(value, salt = SecureRandom.base64)
|
25
|
+
BasicPassword.new(value, salt).to_h
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.check (value, salt, hash)
|
29
|
+
hash == BasicPassword.new(value, salt).hash
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: basic-password
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felipe Cabrera
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email: fecabrera0@outlook.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/basic-password.rb
|
34
|
+
homepage: https://gitlab.com/armizh/basic-password
|
35
|
+
licenses:
|
36
|
+
- BSD-2-Clause
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubygems_version: 3.0.1
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Password generator
|
57
|
+
test_files: []
|