passweird 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f9ca1edca79f1e3509a577234b4bb273753f0a1ad7ec48ce245731a0ee10117
4
- data.tar.gz: d10de41fe650f3d9f3549ef56ec954bd526ebedb943158d7d83ed95c6fea39b1
3
+ metadata.gz: 8a90a6f24240691ccdd65ca1185eeda32e95dfc65302d1eb4fa118a5b8e45504
4
+ data.tar.gz: 463bf49ad884574607e5682bd00de52008fca4ee272e9a49f4723c846d306d1c
5
5
  SHA512:
6
- metadata.gz: 5fa8ea500a7c0303baa3f7f19764cef831b792fb508b400829cfd9d44d4d1a7a797db83abaaf2ee045b86471887f3c059baea54c245c1e21d9982b47ce776ea0
7
- data.tar.gz: 66cb3443e86cad7ceb5f65fd7ad7ce1e641364a5430aa7fc8643052d447e698d324b63ef816ac701ec2663ff4f3d5f923c8ece1abcae0cbc8b5a4cda7ffa6c71
6
+ metadata.gz: 940795845301e0ca6c127c168b70b7731fbfba2c779a95bfacf56bdb830e3d1cedfbc79d95e846da41d558f763e7478402450c5fde7c5e24c524af6ef657d201
7
+ data.tar.gz: e20d91623ec83339f47f662f83787af532146c77964f67aa59f52c9ff584ef0d49ca825f33f588d870b803fb90ac17d6b65e0ed1b0d6ece93ffbcb8563289300
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
13
 
14
- gem "activerecord", "~> 6.0"
14
+ gem "activerecord", ">= 7.0", "< 8.0"
15
15
 
16
16
  gem "sqlite3", "~> 1.4", ">= 1.4.2"
17
17
 
data/Gemfile.lock CHANGED
@@ -1,25 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passweird (0.1.2)
5
- activerecord (~> 6.0)
4
+ passweird (0.2.0)
5
+ activerecord (>= 7.0, < 8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.1.7.10)
11
- activesupport (= 6.1.7.10)
12
- activerecord (6.1.7.10)
13
- activemodel (= 6.1.7.10)
14
- activesupport (= 6.1.7.10)
15
- activesupport (6.1.7.10)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
10
+ activemodel (7.2.2.1)
11
+ activesupport (= 7.2.2.1)
12
+ activerecord (7.2.2.1)
13
+ activemodel (= 7.2.2.1)
14
+ activesupport (= 7.2.2.1)
15
+ timeout (>= 0.4.0)
16
+ activesupport (7.2.2.1)
17
+ base64
18
+ benchmark (>= 0.3)
19
+ bigdecimal
20
+ concurrent-ruby (~> 1.0, >= 1.3.1)
21
+ connection_pool (>= 2.2.5)
22
+ drb
17
23
  i18n (>= 1.6, < 2)
24
+ logger (>= 1.4.2)
18
25
  minitest (>= 5.1)
19
- tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
26
+ securerandom (>= 0.3)
27
+ tzinfo (~> 2.0, >= 2.0.5)
21
28
  ast (2.4.2)
29
+ base64 (0.2.0)
30
+ benchmark (0.4.0)
31
+ bigdecimal (3.1.9)
22
32
  concurrent-ruby (1.3.5)
33
+ connection_pool (2.5.0)
23
34
  database_cleaner (2.1.0)
24
35
  database_cleaner-active_record (>= 2, < 3)
25
36
  database_cleaner-active_record (2.2.0)
@@ -27,10 +38,12 @@ GEM
27
38
  database_cleaner-core (~> 2.0.0)
28
39
  database_cleaner-core (2.0.1)
29
40
  diff-lcs (1.5.1)
41
+ drb (2.2.1)
30
42
  i18n (1.14.7)
31
43
  concurrent-ruby (~> 1.0)
32
44
  json (2.9.1)
33
45
  language_server-protocol (3.17.0.3)
46
+ logger (1.6.5)
34
47
  minitest (5.25.4)
35
48
  parallel (1.26.3)
36
49
  parser (3.3.7.0)
@@ -66,21 +79,22 @@ GEM
66
79
  rubocop-ast (1.37.0)
67
80
  parser (>= 3.3.1.0)
68
81
  ruby-progressbar (1.13.0)
82
+ securerandom (0.4.1)
69
83
  sqlite3 (1.7.3-arm64-darwin)
70
84
  sqlite3 (1.7.3-x86_64-linux)
85
+ timeout (0.4.3)
71
86
  tzinfo (2.0.6)
72
87
  concurrent-ruby (~> 1.0)
73
88
  unicode-display_width (3.1.4)
74
89
  unicode-emoji (~> 4.0, >= 4.0.4)
75
90
  unicode-emoji (4.0.4)
76
- zeitwerk (2.6.18)
77
91
 
78
92
  PLATFORMS
79
93
  arm64-darwin-24
80
94
  x86_64-linux
81
95
 
82
96
  DEPENDENCIES
83
- activerecord (~> 6.0)
97
+ activerecord (>= 7.0, < 8.0)
84
98
  database_cleaner (~> 2.1)
85
99
  passweird!
86
100
  rake (~> 13.0)
@@ -24,7 +24,7 @@ module Passweird
24
24
  #
25
25
  # @return [Boolean] true if the password is blacklisted, false otherwise
26
26
  def blacklisted?
27
- @blacklisted ||= BlacklistedTerm.where(term: possible_terms).exists?
27
+ @blacklisted ||= BlacklistedTerm.exists?(term: possible_terms)
28
28
  end
29
29
 
30
30
  # Retrieves the blacklisted terms that match the possible terms
@@ -47,6 +47,10 @@ module Passweird
47
47
  @all_substring_case_permutations ||= substrings + unleeted_substrings + downcased_substrings + upcased_substrings
48
48
  end
49
49
 
50
+ def all_substrings
51
+ @all_substrings ||= (substrings + unleeted_substrings).uniq
52
+ end
53
+
50
54
  def unleeted_substrings
51
55
  @unleeted_substrings ||= LeetSpeak.unleet_all(substrings)
52
56
  end
@@ -56,11 +60,11 @@ module Passweird
56
60
  end
57
61
 
58
62
  def downcased_substrings
59
- @downcased_substrings ||= substrings.map(&:downcase)
63
+ @downcased_substrings ||= all_substrings.map(&:downcase)
60
64
  end
61
65
 
62
66
  def upcased_substrings
63
- @upcased_substrings ||= substrings.map(&:upcase)
67
+ @upcased_substrings ||= all_substrings.map(&:upcase)
64
68
  end
65
69
  end
66
70
  end
@@ -8,41 +8,92 @@ module Passweird
8
8
  # leet_speak = Passweird::LeetSpeak.new("example")
9
9
  # leet_string = leet_speak.leet
10
10
  # # => "3x4mpl3"
11
- # normal_string = leet_speak.unleeted
11
+ # normal_string = leet_speak.unleet
12
12
  # # => "example"
13
13
  class LeetSpeak
14
14
  attr_reader :given_string
15
15
 
16
- LEET_CHAR_EQUIVALENTS = {
17
- "T" => "7", "t" => "7",
18
- "E" => "3", "e" => "3",
19
- "I" => "1", "i" => "1",
20
- "L" => "1", "l" => "1",
21
- "O" => "0", "o" => "0",
22
- "S" => "5", "s" => "5",
23
- "A" => "4", "a" => "4",
24
- "G" => "6", "g" => "6",
25
- "B" => "8", "b" => "8"
16
+ ALPHABET_TO_SIMPLE_LEET = {
17
+ # Uppercase
18
+ "A" => "4",
19
+ "B" => "8",
20
+ "C" => "(",
21
+ "E" => "3",
22
+ "F" => "ƒ",
23
+ "G" => "6",
24
+ "H" => "#",
25
+ "I" => "1",
26
+ "N" => "И",
27
+ "O" => "0",
28
+ "R" => "Я",
29
+ "S" => "5",
30
+ "T" => "7",
31
+ "U" => "U",
32
+ "Y" => "¥",
33
+ "Z" => "2",
34
+ # Downcase
35
+ "a" => "4",
36
+ "b" => "8",
37
+ "c" => "(",
38
+ "e" => "3",
39
+ "f" => "ƒ",
40
+ "g" => "6",
41
+ "h" => "#",
42
+ "i" => "1",
43
+ "n" => "и",
44
+ "o" => "0",
45
+ "r" => "я",
46
+ "s" => "5",
47
+ "t" => "7",
48
+ "u" => "u",
49
+ "y" => "¥",
50
+ "z" => "2"
26
51
  }.freeze
27
52
 
53
+ # Reference: https://en.wikipedia.org/wiki/Leet#Table_of_leet-speak_substitutes_for_normal_letters
54
+ # Excluded leet speak equivalents that has 3 or more characters
55
+ LEET_TO_ALPHABET = {
56
+ "4" => "A", "@" => "A", "Д" => "A",
57
+ "8" => "B", "ß" => "B",
58
+ "(" => "C", "{" => "C",
59
+ "3" => "E", "£" => "E", "€" => "E",
60
+ "ƒ" => "F",
61
+ "6" => "G", "9" => "G",
62
+ "#" => "H",
63
+ "1" => "I", "!" => "I",
64
+ "И" => "N", "ท" => "N",
65
+ "0" => "O", "Ø" => "O",
66
+ "Я" => "R",
67
+ "5" => "S", "$" => "S",
68
+ "7" => "T",
69
+ "พ" => "W", "₩" => "W", "ω" => "W",
70
+ "¥" => "Y",
71
+ "2" => "Z"
72
+ }.freeze
73
+
74
+
28
75
  def self.leet(given_string)
29
76
  new(given_string).leet
30
77
  end
31
78
 
79
+ def self.leet?(given_string)
80
+ new(given_string).leet?
81
+ end
82
+
32
83
  def self.leet_all(array_of_strings)
33
84
  raise ArgumentError, "array_of_strings must be an Array" unless array_of_strings.is_a?(Array)
34
85
 
35
86
  array_of_strings.map { |string| leet(string) }
36
87
  end
37
88
 
38
- def self.unleeted(given_string)
39
- new(given_string).unleeted
89
+ def self.unleet(given_string)
90
+ new(given_string).unleet
40
91
  end
41
92
 
42
93
  def self.unleet_all(array_of_strings)
43
94
  raise ArgumentError, "array_of_strings must be an Array" unless array_of_strings.is_a?(Array)
44
95
 
45
- array_of_strings.map { |string| unleeted(string) }
96
+ array_of_strings.map { |string| unleet(string) }
46
97
  end
47
98
 
48
99
  def initialize(given_string)
@@ -55,7 +106,7 @@ module Passweird
55
106
  #
56
107
  # @return [String] the converted leet speak string
57
108
  def leet
58
- given_string.gsub(/[#{LEET_CHAR_EQUIVALENTS.keys.join}]/, LEET_CHAR_EQUIVALENTS)
109
+ given_string.gsub(/[#{ALPHABET_TO_SIMPLE_LEET.keys.join}]/, ALPHABET_TO_SIMPLE_LEET)
59
110
  end
60
111
 
61
112
  def leet?
@@ -65,8 +116,8 @@ module Passweird
65
116
  # Converts the leet speak string back to normal text
66
117
  #
67
118
  # @return [String] the converted normal text string
68
- def unleeted
69
- given_string.gsub(/[#{LEET_CHAR_EQUIVALENTS.values.join}]/, LEET_CHAR_EQUIVALENTS.invert)
119
+ def unleet
120
+ given_string.upcase.gsub(/[#{LEET_TO_ALPHABET.keys.join}]/, LEET_TO_ALPHABET)
70
121
  end
71
122
  end
72
123
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passweird
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
data/passweird.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency "activerecord", "~> 6.0"
31
+ spec.add_dependency "activerecord", ">= 7.0", "< 8.0"
32
32
 
33
33
  # For more information and examples about making a new gem, check out our
34
34
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passweird
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rupert Señga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-23 00:00:00.000000000 Z
11
+ date: 2025-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: '7.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '6.0'
32
+ version: '8.0'
27
33
  description:
28
34
  email:
29
35
  - pertsenga@gmail.com