pwned_passwords 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/pwned_passwords.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '040899314b81011390472b0d6d17b12782f2709049fcf157d44b225fb0f4c1b4'
|
4
|
+
data.tar.gz: 4be81b1de548f6eb7da54cdc121c45491e6dcef9290fdae7809e976a81cda5b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a91cb033aa4ff81f04f5d2c78671cbe700b4c59d55741d6beade0233c4f8c7cfb21b54bb1e79769d7ce6dbec6047b40509b3e17324231dc071ea9275157da3a7
|
7
|
+
data.tar.gz: 972e799eba853006cf5abd190eec843756c8f8f36170645f0bb5700b15b391cadbb6ea1630920e57f3fe2607dacb3223f7f29dd65a4091fb8df2c82c2ea330fb
|
data/lib/pwned_passwords.rb
CHANGED
@@ -30,4 +30,25 @@ class PwnedPasswords
|
|
30
30
|
puts "This password is okay"
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
def self.score_password(password)
|
35
|
+
password_score = 0
|
36
|
+
hashed_password = Digest::SHA1.hexdigest password
|
37
|
+
hashed_password.upcase!
|
38
|
+
# get the first five characters
|
39
|
+
hashed_password_prefix = hashed_password[0,5]
|
40
|
+
hashed_password_suffix = hashed_password[5..-1]
|
41
|
+
query_url = "#{PWNED_PASSWORD_API}#{hashed_password_prefix}"
|
42
|
+
api_response = Faraday.get query_url
|
43
|
+
if api_response.body.length > 0
|
44
|
+
suffixes = api_response.body.split("\r\n")
|
45
|
+
suffixes.each do |line|
|
46
|
+
suffix,count = line.split(":")
|
47
|
+
if suffix == hashed_password_suffix
|
48
|
+
password_score = count.to_i
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
password_score
|
53
|
+
end
|
33
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwned_passwords
|
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
|
- Oliver Day
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Checks against the Pwned Passwords API using the first five characters
|
14
14
|
of the SHA1 hash of a password to determine if it exists in previously disclosed
|