# monoalphabetic substitution cipher
plain  = "abcdefghijklmnopqrstuvwxyz"
key    = "qwertyuiopasdfghjklzxcvbnm"

def encrypt(text):
    out = ""
    for ch in text:
        if ch in plain:
            out += key[plain.index(ch)]
        else:
          out += ch
    return out

def decrypt(text):
    out = ""
    for ch in text:
        if ch in key:
            out += plain[key.index(ch)]
        else:
            out += ch
    return out


msg = "hello world"
c = encrypt(msg)
print("plain text :", msg)
print("cipher text:", c)
print("decrypted  :", decrypt(c))
