Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

write a function decipher that takes 2 arguments: ciphertext, knownWord and return the…

  1. User

    write a function decipher that takes 2 arguments: ciphertext, knownWord and return the original unencrypted string, given the encryption algorithm simply shifts all characters by he same amount

  2. Assistant
    def decipher(ciphertext, knownWord):
        for shift in range(256):
            plaintext = ''.join([chr((ord(c) - shift)%256) for c in ciphertext])
            if knownWord in plaintext:
                return plaintext
        return None