Initial QSfera import

This commit is contained in:
Курнат Андрей
2026-06-07 10:20:04 +03:00
commit 2315f25754
16485 changed files with 4826827 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
package match
import (
"encoding/json"
)
type Match struct {
Pattern string `json:"pattern"`
I int `json:"i"`
J int `json:"j"`
Token string `json:"token"`
// Dictionary
Reversed bool `json:"reversed,omitempty"`
UppercaseVariations float64 `json:"uppercase_variations,omitempty"`
L33tVariations float64 `json:"l33t_variations,omitempty"`
MatchedWord string `json:"matched_word,omitempty"`
Rank int `json:"rank,omitempty"`
DictionaryName string `json:"dictionary_name,omitempty"`
L33t bool `json:"l33t,omitempty"`
Sub map[string]string `json:"sub,omitempty"`
// Sequence
Graph string `json:"graph,omitempty"`
SequenceName string `json:"sequence_name,omitempty"`
SequenceSpace int `json:"sequence_space,omitempty"`
Ascending bool `json:"ascending,omitempty"`
Turns int `json:"turns,omitempty"`
ShiftedCount int `json:"shifted_count,omitempty"`
// Repeat
BaseToken string `json:"base_token,omitempty"`
BaseGuesses float64 `json:"base_guesses,omitempty"`
BaseMatches []*Match `json:"base_matches,omitempty"`
RepeatCount int `json:"repeat_count,omitempty"`
// Regexp
RegexName string `json:"regex_name,omitempty"`
// Date
Year int `json:"year,omitempty"`
Month int `json:"month,omitempty"`
Day int `json:"day,omitempty"`
Separator string `json:"separator,omitempty"`
Entropy float64 `json:"entropy,omitempty"`
Guesses float64 `json:"guesses,omitempty"`
}
type Matcher interface {
Matches(password string) []*Match
}
// ToString returns a string representation of a sequence of matches
func ToString(matches []*Match) string {
b, _ := json.Marshal(matches)
return string(b)
}
+27
View File
@@ -0,0 +1,27 @@
package match
import (
"sort"
)
type matchesByIJ []*Match
func (s matchesByIJ) Len() int {
return len(s)
}
func (s matchesByIJ) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s matchesByIJ) Less(i, j int) bool {
if s[i].I < s[j].I {
return true
} else if s[i].I == s[j].I {
return s[i].J < s[j].J
} else {
return false
}
}
func Sort(matches []*Match) {
sort.Stable(matchesByIJ(matches))
}