easy-password 0.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22d9fd1676c83cd88d002fbc80e9f99727e524c704027a2d4d37078c17c5234d
4
- data.tar.gz: 325356f44444034a31212ee79b0e2e92bb7392314351df8e4b78985baa09acb9
3
+ metadata.gz: 54a098d1ce47983b62a9974c8e0a58c16cd7c8e8615471ef87a71a212570c96d
4
+ data.tar.gz: 0a2160479a05388c034b4afa854647e8332515bf818231ee3de7148c378cdeb3
5
5
  SHA512:
6
- metadata.gz: 67ffa6ec83d80b16bbcbddb2f649fe183b97d2753e018c35deb3a2fd27f6652af2cb191fa26282fde1c1020a97cdf5a6f995c7d1d70323ecbb9d7c8ead00b21c
7
- data.tar.gz: 5763ce1f321402431fea4169d1bbb351adc6e33223eb1d2744970fd94aa73762b8dcd0e0b78114a939958847c80d5f8895ea775efb85d0c1f6d613102bbf8031
6
+ metadata.gz: cd75d1a35f64b1fd1f66895fdb8013a4023619277a8942539c929253ff0447e5ee760b20826858d23c55cb1ef63bb9c865b5986614366174909cf099977cbf19
7
+ data.tar.gz: 460e9b33b168c2deb2e75d3fb8a07670e4330202370d2c3ed8752d436f0b0700edaba01456333a0203152423fba0c62368a1d6276b1b31900a9383a557c2e828
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  * hashing password to sha256, md5, sha, ntlm, lmhash
14
14
  EOF
15
15
 
16
- s.homepage = 'https://gitlab.com/sdalu/easy-password'
16
+ s.homepage = 'https://github.com/sdalu/easy-password'
17
17
  s.license = 'MIT'
18
18
 
19
19
  s.authors = [ "Stéphane D'Alu" ]
@@ -0,0 +1,65 @@
1
+ require 'stringio'
2
+
3
+ class EasyPassword
4
+
5
+ private
6
+
7
+ # Source: https://gist.github.com/frezbo/08eb7064a33ad3d8a853cc80b874201f
8
+ def self.digest_md4(string)
9
+ # functions
10
+ mask = (1 << 32) - 1
11
+ f = proc {|x, y, z| x & y | x.^(mask) & z}
12
+ g = proc {|x, y, z| x & y | x & z | y & z}
13
+ h = proc {|x, y, z| x ^ y ^ z}
14
+ r = proc {|v, s| (v << s).&(mask) | (v.&(mask) >> (32 - s))}
15
+
16
+ # initial hash
17
+ a, b, c, d = 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476
18
+
19
+ bit_len = string.size << 3
20
+ string += "\x80"
21
+ while (string.size % 64) != 56
22
+ string += "\0"
23
+ end
24
+ string = string.force_encoding('ascii-8bit') +
25
+ [bit_len & mask, bit_len >> 32].pack("V2")
26
+
27
+ if string.size % 64 != 0
28
+ fail "failed to pad to correct length"
29
+ end
30
+
31
+ io = StringIO.new(string)
32
+ block = ""
33
+
34
+ while io.read(64, block)
35
+ x = block.unpack("V16")
36
+
37
+ # Process this block.
38
+ aa, bb, cc, dd = a, b, c, d
39
+ [0, 4, 8, 12].each {|i|
40
+ a = r[a + f[b, c, d] + x[i], 3]; i += 1
41
+ d = r[d + f[a, b, c] + x[i], 7]; i += 1
42
+ c = r[c + f[d, a, b] + x[i], 11]; i += 1
43
+ b = r[b + f[c, d, a] + x[i], 19]
44
+ }
45
+ [0, 1, 2, 3].each {|i|
46
+ a = r[a + g[b, c, d] + x[i] + 0x5a827999, 3]; i += 4
47
+ d = r[d + g[a, b, c] + x[i] + 0x5a827999, 5]; i += 4
48
+ c = r[c + g[d, a, b] + x[i] + 0x5a827999, 9]; i += 4
49
+ b = r[b + g[c, d, a] + x[i] + 0x5a827999, 13]
50
+ }
51
+ [0, 2, 1, 3].each {|i|
52
+ a = r[a + h[b, c, d] + x[i] + 0x6ed9eba1, 3]; i += 8
53
+ d = r[d + h[a, b, c] + x[i] + 0x6ed9eba1, 9]; i -= 4
54
+ c = r[c + h[d, a, b] + x[i] + 0x6ed9eba1, 11]; i += 8
55
+ b = r[b + h[c, d, a] + x[i] + 0x6ed9eba1, 15]
56
+ }
57
+ a = (a + aa) & mask
58
+ b = (b + bb) & mask
59
+ c = (c + cc) & mask
60
+ d = (d + dd) & mask
61
+ end
62
+
63
+ [a, b, c, d].pack("V4")
64
+ end
65
+ end
@@ -1,5 +1,5 @@
1
1
  class EasyPassword
2
2
  # Version
3
- VERSION = '0.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
 
data/lib/easy-password.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'openssl'
2
+ require_relative 'easy-password/md4'
2
3
 
3
4
  #
4
5
  # Adding a simple password generator and using it by default:
@@ -206,7 +207,10 @@ class EasyPassword
206
207
  # @return [String] hashed password
207
208
  #
208
209
  def self.ntlm(password)
209
- Digest::MD4.hexdigest(password.encode("utf-16le"))
210
+ # New version of OpenSSL doesn't provide MD4 anymore
211
+ # Digest::MD4.hexdigest(password.encode("utf-16le"))
212
+ self.digest_md4(password.encode("utf-16le").force_encoding('BINARY'))
213
+ .unpack1('H*')
210
214
  end
211
215
 
212
216
 
@@ -236,6 +240,12 @@ class EasyPassword
236
240
  end
237
241
 
238
242
 
243
+ # Override equality
244
+ def ==(other)
245
+ !other.nil? && other.is_a?(EasyPassword) && self.raw == other.raw
246
+ end
247
+
248
+
239
249
  # Get the plain text password
240
250
  #
241
251
  # @return [String] plain text password
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-password
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stéphane D'Alu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-27 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -66,8 +66,9 @@ files:
66
66
  - README.md
67
67
  - easy-password.gemspec
68
68
  - lib/easy-password.rb
69
+ - lib/easy-password/md4.rb
69
70
  - lib/easy-password/version.rb
70
- homepage: https://gitlab.com/sdalu/easy-password
71
+ homepage: https://github.com/sdalu/easy-password
71
72
  licenses:
72
73
  - MIT
73
74
  metadata: {}
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.0.8
90
+ rubygems_version: 3.5.14
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: Password generator, checker, hasher