Skip to main content

Featured

Solving Economic Crisis Without Work-From-Home: A Systems Approach to Resource Prioritization

  1. The Economic Problem: Diagnosing the Crisis Type 1.1 Crisis Typology and Sector Dynamics Currency crises typically emerge from one or more of these imbalances: Current account deficits — Imports exceed exports; forex drains to cover the gap Capital account withdrawal — Foreign investors exit; hot money leaves Inflation-driven overvaluation — Real exchange rate strengthens despite nominal devaluation Debt servicing burden — External debt payouts drain reserves faster than exports can cover The empirical record shows that currency crises are sectoral crises —not aggregate demand crises. When Argentina devalued 75% in 2001, the economy contracted 10.9%, but manufacturing capacity utilization recovered within 18 months because input costs fell (Hausmann & Velasco, 2002). When Vietnam reformed in 1986, manufacturing capacity expansion drove recovery before demand-side effects materialized. Critical insight: Resource reallocation works when the constraint is supply-sid...

Python Project Encoding to ASCII,Base64 and more

 import base64

import binascii
import codecs
from Crypto.Cipher import AES, DES

def encode_ascii(text):
    return ' '.join(str(ord(char)) for char in text)

def encode_unicode(text):
    return ' '.join(hex(ord(char)) for char in text)

def encode_base64(text):
    return base64.b64encode(text.encode()).decode()

def encode_binary(text):
    return ' '.join(format(ord(char), '08b') for char in text)

def encode_morse_code(text):
    morse_code_dict = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---',
                      'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-',
                      'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', ' ': '|'}
    return ' '.join(morse_code_dict.get(char.upper(), char) for char in text)

def encode_utf8(text):
    return codecs.encode(text, 'utf-8')

def encode_caesar_cipher(text, shift):
    result = ''
    for char in text:
        if char.isalpha():
            ascii_offset = ord('A') if char.isupper() else ord('a')
            result += chr((ord(char) - ascii_offset + shift) % 26 + ascii_offset)
        else:
            result += char
    return result

def encode_aes(text, key):
    cipher = AES.new(key.encode(), AES.MODE_ECB)
    return cipher.encrypt(text.encode()).hex()

def encode_des(text, key):
    cipher = DES.new(key.encode(), DES.MODE_ECB)
    return cipher.encrypt(text.encode()).hex()

def encode_all(text):
    encodings = {
        "ASCII": encode_ascii(text),
        "Unicode": encode_unicode(text),
        "Base64": encode_base64(text),
        "Binary": encode_binary(text),
        "Morse Code": encode_morse_code(text),
        "UTF-8": encode_utf8(text),
       
        # Add more encodings here if needed
    }
    return encodings

def select_encoding_type():
    print("\nSelect encoding type:")
    print("1. ASCII")
    print("2. Unicode")
    print("3. Base64")
    print("4. Binary")
    print("5. Morse Code")
    print("6. UTF-8")
    print("7. Caesar Cipher")
    print("8. AES")
    print("9. DES")
    print("0. Quit")
    choice = input("Enter the corresponding number (or 'q' to quit): ")
    return choice

def main():
    while True:
        text_to_encode = input("\nEnter the text to encode (or 'q' to quit): ")
        if text_to_encode.lower() == 'q':
            break
        encodings = encode_all(text_to_encode)
        for encoding, encoded_text in encodings.items():
            print(f"{encoding}: {encoded_text}")

if __name__ == "__main__":
    main()

Comments

Popular Posts