utils

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package utils provides utility functions for the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckASCIIString

func CheckASCIIString(str string) bool

CheckASCIIString checks to see if a string only contains ascii characters

Args:

str (string): Input string to check

Returns:

(bool): If the string only contained ASCII characters

func CheckAreArraysEqual

func CheckAreArraysEqual(a, b []string) bool

CheckAreArraysEqual checks if two arrays are equal by comparing the length of the arrays and the values of the elements in the arrays. If the arrays are equal, the function returns true, otherwise it returns false.

Args: a ([]string): The first array to compare b ([]string): The second array to compare

Returns: bool: True if the arrays are equal, false otherwise

func CheckAreMapsEqual

func CheckAreMapsEqual(a, b map[string]int) bool

CheckAreMapsEqual checks if two maps are equal by comparing the length of the maps and the values of the keys in the maps. If the maps are equal, the function returns true, otherwise it returns false.

Args:

a (map[string]int): The first map to compare
b (map[string]int): The second map to compare

Returns:

bool: True if the maps are equal, false otherwise

func CheckHexString

func CheckHexString(s string) bool

CheckHexString is used to identify plaintext in the $HEX[...] format

Args:

s (str): The string to be evaluated

Returns:

(bool): Returns true if it matches and false if it did not

func CombineMaps

func CombineMaps(maps ...map[string]int) map[string]int

CombineMaps combines any number of maps into a single map combining values for common keys and returning a new map

Args: maps ([]map[string]int): The maps to combine

Returns: map[string]int: A new map combining the values of the input maps

func ConvertMultiByteCharToIteratingRule

func ConvertMultiByteCharToIteratingRule(index int, str string) string

ConvertMultiByteCharToIteratingRule converts non-ascii characters to a hashcat valid format for rule.CharToIteratingRule functions

Args:

index (int): Index to start the iteration
str (string): Input string to transform

Returns:

returnStr (string): Converted string

func ConvertMultiByteCharToRule

func ConvertMultiByteCharToRule(str string) string

ConvertMultiByteCharToRule converts non-ascii characters to a hashcat valid format for rule.CharToRule functions

Args:

str (string): Input string to transform

Returns:

returnStr (string): Converted string

func IncrementIteratingRuleCall

func IncrementIteratingRuleCall(s string) string

IncrementIteratingRuleCall increments the last character of a string for rules.CharToIteratingRules functions

For example, "i4" will be incremented to "i5", "iA" will be incremented to "IB"

Args:

s (string): Input string to increment

Returns:

output (string): Incremented string

func LoadStdinToMap

func LoadStdinToMap(scanner models.Scanner) (map[string]int, error)

LoadStdinToMap reads the contents of stdin and returns a map[string]int where the key is the line and the value is the frequency of the line in the input

Args:

scanner (models.Scanner): The scanner to read from stdin

Returns:

map[string]int: A map of lines from stdin
error: An error if one occurred

func ProcessURL

func ProcessURL(url string, ch chan<- string, wg *sync.WaitGroup)

ProcessURL reads the contents of a URL and sends each sentence to the channel

Args:

url (string): The URL to read
ch (chan<- string): The channel to send the sentences to
wg (*sync.WaitGroup): The WaitGroup to signal when done

Returns:

None

func ReadFilesToMap

func ReadFilesToMap(fs models.FileSystem, filenames []string) map[string]int

ReadFilesToMap reads the contents of the multiple files and returns a map of words

Args:

fs (FileSystem): The filesystem to read the files from (used for testing)
filenames ([]string): The names of the files to read

Returns:

(map[string]int): A map of words from the files

func ReadURLsToMap

func ReadURLsToMap(urls []string) (map[string]int, error)

ReadURLsToMap reads the contents of the multiple URLs and returns a map of words from the URLs

Args:

urls ([]string): The URLs to read

Returns:

map[string]int: A map of words from the URLs
error: An error if one occurred

func ReplaceSubstring

func ReplaceSubstring(original string, replacements map[string]int) []string

ReplaceSubstring replaces all instances of a substring in a string with a new substring if the substring is found in the original string. The new substring is determined by the key in the replacements map separated by a colon character.

Args:

original (string): The original string
replacements (map[string]int): A map of substrings to replace

Returns:

[]string: The original string with all instances of the substring replaced

func ReverseString

func ReverseString(s string) string

ReverseString will return a string in reverse

Args:

str (string): Input string to transform

Returns:

(string): Transformed string

func SplitBySeparatorString

func SplitBySeparatorString(s string, sep string) []string

SplitBySeparatorString splits a string by a separator string and returns a slice with the separator string included

Args:

s (string): The string to split
sep (string): The separator string

Returns:

[]string: A slice of strings with the separator string included

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL