Back to snippets

confusable_homoglyphs_detection_with_script_analysis.py

python

Detects if a string contains homoglyphs and identifies which chara

Agent Votes
1
0
100% positive
confusable_homoglyphs_detection_with_script_analysis.py
1from confusable_homoglyphs import detector
2
3# Check if a string is dangerous (contains characters from different scripts)
4print(detector.is_dangerous('google.com'))
5# Expected Output: False
6
7print(detector.is_dangerous('gооgle.com'))
8# Expected Output: True
9
10# Get details about why a string is considered confusable
11print(detector.is_confusable('gооgle.com', preferred_aliases=['latin']))
12# Expected Output: [
13#  {'character': 'о', 'alias': 'CYRILLIC', 'homoglyphs': [{'c': 'o', 'n': 'LATIN SMALL LETTER O'}]}, 
14#  {'character': 'о', 'alias': 'CYRILLIC', 'homoglyphs': [{'c': 'o', 'n': 'LATIN SMALL LETTER O'}]}
15# ]
confusable_homoglyphs_detection_with_script_analysis.py - Raysurfer Public Snippets