
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Over simplistic fuzzy search library using Damerau-Levenshtein and optionally the keyboard layout to calculate distances.
Over simplistic fuzzy search library using Damerau-Levenshtein and optionally the keyboard layout to calculate distances.
FuzzyDist
is a simple tool for calculating the Damerau-Levenshtein distance between two strings. This class also supports optional keyboard-specific distance calculations, allowing for more nuanced distance measurements based on the layout of different keyboards.
npm install fuzzy-dist
To calculate the standard Damerau-Levenshtein distance between two strings, simply instantiate the FuzzyDist
class without specifying a keyboard layout.
import FuzzyDist from 'fuzzy-dist';
const fuzzyDist = new FuzzyDist();
const distance = fuzzyDist.calculateDistance('kitten', 'sitten');
console.log(distance); // Outputs: 1
To include keyboard distance in the Damerau-Levenshtein calculation, you can specify a keyboard layout when instantiating the FuzzyDist
class. This will add an additional layer of accuracy by taking into account the physical distance between keys on a specified keyboard.
import FuzzyDist from 'fuzzy-dist';
const fuzzyDistQwerty = new FuzzyDist(FuzzyDist.QwertyKeyboard);
const distance = fuzzyDistQwerty.calculateDistance('kitten', 'sitten');
console.log(distance); // Outputs: 2
const distanceWithKeyboard = fuzzyDistQwerty.calculateDistance('kitten', 'oitten');
console.log(distanceWithKeyboard); // Outputs: 1.4
const distanceWithKeyboard = fuzzyDistQwerty.calculateDistance('kitten', 'jitten');
console.log(distanceWithKeyboard); // Outputs: 1
The FuzzyDist
class also provides a method to find the closest match to a target string from an array of strings.
import FuzzyDist from './FuzzyDist';
const fuzzyDist = new FuzzyDist(FuzzyDist.QwertyKeyboard);
const target = 'hello';
const strings = ['hallo', 'hullo', 'hero', 'hell'];
const minDistance = fuzzyDist.getMinimumDistance(target, strings);
console.log(minDistance); // Outputs the minimum distance, e.g., 1
The FuzzyDist
class supports the following keyboard layouts:
constructor(keyboardId: number | null | undefined = null)
null
, the standard Damerau-Levenshtein distance is calculated without considering keyboard layout.calculateDistance(s1: string, s2: string): number
Calculates the Damerau-Levenshtein distance between two strings, optionally considering keyboard layout if specified in the constructor.
getMinimumDistance(target: string, strings: string[]): number
Finds and returns the minimum Damerau-Levenshtein distance between a target string and an array of strings.
MIT © Remotal
FAQs
Over simplistic fuzzy search library using Damerau-Levenshtein and optionally the keyboard layout to calculate distances.
We found that fuzzy-dist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.