Sunday, 23 January 2022

Write a Python program to display plain text and cipher text using a Caesar encryption.

Slip 14 Q 2

CODE :


def encypt_func(txt, s):  
    result = ""  
    for i in range(len(txt)):  
        char = txt[i]
        if (char.isupper()):  
            result += chr((ord(char) + s - 64) % 26 + 65)
        else:  
            result += chr((ord(char) + s - 96) % 26 + 97)  
    return result  

txt = input('Enter a string : ')
s = int(input('ENtER number to shift pattern encript : '))
 
print("Plain txt : " + txt)  
print("Shift pattern : " + str(s))  
print("Cipher: " + encypt_func(txt, s))  

OUTPUT :




No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...