Dcoder¶
Overview¶
Welcome to dcoder’s Documentation!
docder is a python module that provides various functions for decoding/encoding text. It also has functions for encrypting or decrypting text in various ciphers.
Warning
This module requires Python 3.6 and above due to the use of f-strings in the source code.
It is designed to be simple and easy to use. The functions are very self explanatory but if you need help you can always read the docs here!
Installation¶
You can install released versions of dcoder from the Python Package Index with pip or a similar tool:
Stable Release:¶
pip install dcoder
Working Version:¶
pip install git+https://github.com/CodeWithSwastik/dcoder.git
Basic Usage:¶
>>> import dcoder
>>> dcoder.text2hex("Hello!") #Encodes the string and returns the hex string
'48 65 6c 6c 6f 21'
>>> dcoder.hex2text("48 69 20 74 68 65 72 65 21") #Decodes the hex string and returns the plain text
'Hi there!'
>>> dcoder.text2caesar("How are you?") #Encrypts the text in caesar's cipher and returns it
'Krz duh brx?'
>>> dcoder.caesar2text("L dp ilqh, wkdqn brx.") #Decrypts the cipher text and returns the decrypted text
'I am fine, thank you.'
Functions for Decoding¶
This section of this documentation contains information on functions for decoding and decrypting.
-
dcoder.dcodefuncs.
ascii2text
(ascii_text)¶ Takes in a string ascii_text, returns the decoded plain text.
-
dcoder.dcodefuncs.
atbash2text
(encrypted_text)¶ Returns the decrypted text after decrypting the encrypted_text
- Parameters:
encrypted_text (str): The encrypted text in Atbash cipher
- Returns:
translated (str): The decrypted text
-
dcoder.dcodefuncs.
bin2text
(binary_text)¶ Takes in a string binary_text, returns the decoded plain text.
-
dcoder.dcodefuncs.
caesar2text
(encrypted_text, shift=3)¶ Returns the decrypted text after decrypting the encrypted_text
- Parameters:
encrypted_text (str): The encrypted text in Caesar’s cipher shift (int): The shift that should be used to decrypt the text
- Returns:
translated (str): The decrypted text
-
dcoder.dcodefuncs.
caesarBruteforce
(encrypted_text)¶ Returns a list of all the possibilities after decrypting the encrypted_text without using a shift.
- Parameters:
encrypted_text (str): The encrypted text in Caesar’s cipher
- Returns:
possibilities (list): All the possibilities of decryption
-
dcoder.dcodefuncs.
capitalLettersCipher
(ciphertext)¶ Returns the capital letters in the ciphertext
- Parameters:
ciphertext (str): The encrypted text
- Returns:
plaintext (str): The decrypted text
Example:
Cipher Text: dogs are cuter than HorsEs in a LooP.
Decoded Text: HELP
-
dcoder.dcodefuncs.
firstLetterCipher
(ciphertext)¶ Returns the first letters of each word in the ciphertext
- Parameters:
ciphertext (str): The encrypted text
- Returns:
plaintext (str): The decrypted text
Example:
Cipher Text: Horses evertime look positive
Decoded text: Help
-
dcoder.dcodefuncs.
hex2text
(hex_text)¶ Takes in a string hex_text, returns the decoded plain text.
-
dcoder.dcodefuncs.
oct2text
(oct_text)¶ Takes in a string oct_text, returns the decoded plain text.
-
dcoder.dcodefuncs.
railfence2text
(cipher, key=3)¶ Returns the decrypted text after decrypting the encrypted_text.
- Parameters:
encrypted_text (str): The encrypted text in railfence cipher key (int): The Key or the height of the rails
- Returns:
translated (str): The decrypted text
-
dcoder.dcodefuncs.
railfenceBruteforce
(encrypted_text)¶ Returns a list of all the possibilities after decrypting the encrypted_text without using a shift.
- Parameters:
encrypted_text (str): The encrypted text in Railfence Cipher
- Returns:
possibilities (list): All the possibilities of decryption
-
dcoder.dcodefuncs.
reverse
(text)¶ Takes in a string text, returns the text reversed
Functions for Encoding¶
This section of this documentation contains information on functions for encoding and encrypting.
-
dcoder.encodefuncs.
text2ascii
(text)¶ Takes in a string text, returns the encoded text in ascii.
-
dcoder.encodefuncs.
text2atbash
(text)¶ Returns the encrypted text after encrypting the text
- Parameters:
text (str): The text that needs to be encrypted in the Atbash cipher
- Returns:
translated (str): The encrypted text
-
dcoder.encodefuncs.
text2bin
(text)¶ Takes in a string text, returns the encoded text in bin.
-
dcoder.encodefuncs.
text2caesar
(text, shift=3)¶ Returns the encrypted text after encrypting the text with the given shift
- Parameters:
text (str): The text that needs to be encrypted in Caesar’s cipher shift (int): The shift that should be used to encrypt the text
- Returns:
result (str): The encrypted text
-
dcoder.encodefuncs.
text2hex
(text)¶ Takes in a string text, returns the encoded text in hex.
-
dcoder.encodefuncs.
text2oct
(text)¶ Takes in a string text, returns the encoded text in oct.
-
dcoder.encodefuncs.
text2railfence
(text, key=3)¶ Returns the encrypted text after encrypting the text with the given key
- Parameters:
text (str): The text that needs to be encrypted in the Railfence cipher key (int): The Key that should be used to encrypt the text
- Returns:
encrypted (str): The encrypted text