Skip to main content

1337 translator lib

Project description

leetit

1337 translator lib

Instalation

$ pip install leetit

Usage

Simple example:

import leetit
 
print(leetit.leet("xacker"))
print(leetit.leet("xacker", seed=12345, percent=30))

Transformations

In order to get a leetspeak from ordinary English, you need to make three transformations:
First you need to replace words and phrases with slang acronyms like "nice one" => "n1" or "owned" => "pwnd". To do this, the leetit library provides the acronyms function, which accepts text and an optional seed for the PRNG.

import leetit

print(leetit.acronyms("yeah, easy"))
print(leetit.acronyms("yeah, easy", seed=12345))

Secondly, you need to change the morphology of words, for example, replacing the suffixes -er and -or with -xor or -zor. To do this, the leetit library provides the morphology function.

import leetit

print(leetit.morphology("xacker"))
print(leetit.morphology("xacker", seed=12345))

Thirdly, you need to replace all or some of the characters with others similar to them in various ways, for example, e can be replaced with 3 or &. To do this, the substitution function is provided. In addition to text, this function can also accept the following parameters:

  1. The "seed" parameter accepts the seed for the rng.
  2. The "percent" parameter specifies which part of the letters will be changed.
  3. The "alphabet" parameter accepts a dictionary describing the rules for replacing letters (about dictionaries below).
  4. The "chars" parameter accepts a list of letters for which replacement will be performed. By default, all Latin letters are included in this list.

Alphabets

Alphabets are dictionaries in which lowercase letters act as the key, and arrays with characters with which this letter can be replaced as the value.
The leetit library provides several alphabets out of the box:

  • leetit.ALPHABET_NUMBERS - contains options for replacing letters with numbers. For example, e to 3.
  • leetit.ALPHABET_ASCII - contains everything that is in leetit.ALPHABET_NUMBERS, and in addition options for replacing letters with other letters and combinations of letters and numbers. For example, e to &.
  • leetit.ALPHABET_UNICODE_ONLY - contains options for replacing latin letters with special characters and letters of other languages.
  • leetit.ALPHABET_UNICODE - contains a union of leetit.ALPHABET_ASCII and leetit.ALPHABET_UNICODE_ONLY

You can also compose your alphabets.

import leetit

print(leetit.substitution("To be, or not to be, that is the question"))
print(leetit.substitution("To be, or not to be, that is the question", seed=12345))
print(leetit.substitution("To be, or not to be, that is the question", percent=100, alphabet=leetit.ALPHABET_NUMBERS))
print(leetit.substitution("To be, or not to be, that is the question", percent=100, alphabet=leetit.ALPHABET_ASCII))
print(leetit.substitution("To be, or not to be, that is the question", percent=100, alphabet=leetit.ALPHABET_UNICODE_ONLY))
print(leetit.substitution("To be, or not to be, that is the question", percent=100, alphabet=leetit.ALPHABET_UNICODE))

MY_ALPHABET = {
  "e": ["eeeeeeee"],
  "o": ["oooooooo"],
}

print(leetit.substitution("To be, or not to be, that is the question", percent=100, alphabet=MY_ALPHABET))

And finally, the leetit library provides a leet function that performs all three transformations on the text in turn:

def leet(text: str, seed: int = 1337, percent:int = 50, alphabet = ALPHABET_ASCII, chars = string.ascii_lowercase) -> str
import leetit
 
print(leetit.leet("To be, or not to be, that is the question"))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leetit-313.3.73.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leetit-313.3.73-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file leetit-313.3.73.tar.gz.

File metadata

  • Download URL: leetit-313.3.73.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Linux/5.10.69

File hashes

Hashes for leetit-313.3.73.tar.gz
Algorithm Hash digest
SHA256 f14864478635952b5d8e7237314ce2cba75bb004f746882c4ccc65887ebf4295
MD5 f557d019d58e31483f0f01a89767bd1b
BLAKE2b-256 e7e17516a29eb8a28467efed613b1a2f1cfb8ecc4b119348e6b48d71581876d3

See more details on using hashes here.

File details

Details for the file leetit-313.3.73-py3-none-any.whl.

File metadata

  • Download URL: leetit-313.3.73-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Linux/5.10.69

File hashes

Hashes for leetit-313.3.73-py3-none-any.whl
Algorithm Hash digest
SHA256 229b96bd24e259465fe384d33f7f874d766b8f6135af64af34365bd72d467aeb
MD5 3800be821be689604067d9f50afbdaea
BLAKE2b-256 17629034706a80fe6c46e15e2e6a1bf27e899e3f0e2ca56c607e0eaf645f7abf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page