Results 1 to 1 of 1
  1. #1
    Matthew's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    5,327
    Reputation
    1162
    Thanks
    1,156

    Text Encrypted using Caesar Cipher Formula

    Just a little project I had to code for my Python class. You input the text and a distance value (for the cipher) and it encrypts the text and creates a .txt file on your desktop with the encrypted text. It also opens that .txt file and copies the encryption into another newly created .txt file.

    Code:
    plainMessage = input('Enter a message: ') #user inputs text
    distance = int(input('Enter the distance value: ')) #user inputs distance value
    encryptText = ''
    for ch in plainMessage: #caesar cipher formula
        ordValue = ord(ch)
        cipherValue = ordValue + distance
        encryptText += chr(cipherValue)
    file = open('encrypt.txt', 'w') #cipher text to .txt file
    file.write(encryptText) 
    file.close()
    
    with open('encrypt.txt') as file: #.txt file read/copied to another .txt file
        copyText = file.read()
        file = open('copyfile.txt', 'w')
        file.write(copyText)
        file.close()
    Coded this in IDLE and to anyone learning Python I recommend being OCD about syntax and how you format your code (either single quotes all throughout not mixed, indentation, proper variable naming format, etc)
    Last edited by Matthew; 09-26-2020 at 07:14 PM.

Similar Threads

  1. [Release] Basic text encrypter
    By xFishx in forum Visual Basic Programming
    Replies: 32
    Last Post: 12-10-2012, 03:53 AM
  2. [Tutorial] Efficient Text GUI Using Loops
    By infexious in forum Minecraft Tutorials
    Replies: 2
    Last Post: 05-25-2012, 09:57 AM
  3. [Source Code] Simple Text Encryption
    By Defcon 1 in forum C++/C Programming
    Replies: 8
    Last Post: 11-16-2011, 04:30 PM
  4. When i use Black cipher 5
    By MixLix in forum Combat Arms Help
    Replies: 3
    Last Post: 07-02-2011, 03:08 PM
  5. [VB][Release] Text Encrypter
    By CoderNever in forum Visual Basic Programming
    Replies: 2
    Last Post: 09-27-2009, 11:03 PM