Poison Cryptography: Decoding

Poison Cryptography: Decoding

Introduction

Poison Cryptography is a simple encryption technique that involves substituting characters to decode encoded messages. In this example, we'll explore the decoding process using Python.

Decoding (Decrypting)

Functionality

Decoding messages encoded with Poison Cryptography involves using two essential functions:

  • Poisonal: This function takes an encoded message and a decryption key as input. It reverses the Poison Cryptography by substituting characters and numbers with their original values, ultimately returning the original text.
  • ReversePoison: Responsible for reversing the Poison Cryptography by mapping characters back to their original values.

Example



import string

def Poisonal(text, key):

    dec = []

    start = ord('a')

    m = len(key)

    for i in range(len(text)):

        l = text[i]

        k = key[i % m]

        shift = ord(k) - start

        pos = start + (ord(l) - start - shift) % 26  # Reverse the shift

        dec.append(chr(pos))

    return ''.join(dec)

def ReversePoison(S):

    D = ""

    poisonChars = "azbycxdwevfugthsirjqkplomn"

    poisonNums = "0918273645"

    for c in S:

        if c in poisonChars:

            o = poisonChars.index(c)

            D += string.ascii_lowercase[o]

        elif c in poisonNums:

            o = poisonNums.index(c)

            D += str(o)

        else:

            D += c

    return D

encoded_text = "xdislqwqlqlchb"

key = "hhej"

# Decrypt using Poisonal

decrypted_text = Poisonal(encoded_text, key)

# Reverse the Poison Cryptography

original_text = ReversePoison(decrypted_text)

print("Decoded Text is:", original_text)

Summary

Decoding messages encoded with Poison Cryptography can be achieved by utilizing the provided Python code. The Poisonal function is used to reverse the encoding, while the ReversePoison function maps characters and numbers back to their original values. This process allows you to recover the original text from an encoded message.