Thursday, December 7, 2017

how to cipher your message or text with python at codelent

As a genius, some are times we have to keep some of our message, source code or relivant text or
document secret from people due to security reasons.
today i just want to share with you a little method that you can use to cipher or encrypt your document or text for security reasons with a little python program


TEST THE FOLLOWING CODE
#Example 1
#cipher

message = raw_input(' input your message for encryption')

translated = ''
i = len(message) - 1
while i >= 0:
    translated = translated + message[i]
    i = i - 1
print (translated)

def decipher(message):
    translated = ''
    i = len(message) - 1
    if i >= 0:
        translated = translated + message[i]
        i = i - 1
        print translated

now when you run this script it will ask you to input your message or document, after you input
it then click enter key to give you the output.
in other to reverse the process you call the "decipher" method like this:
 decipher(input the printed message here) and tap ok or enter key to reverse the message.

#Example 2

#cipher
message = raw_input(' input your message for encryption')

translated = ''
num = "0000"
i = len(message) - 1
while i >= 0:
    translated = translated + num + message[i]
    i = i - 1
print (translated)

# decipher your
def decipher(message):
        if '0' in str(message):
            k = message.replace('0','')
            translated = ''
            i = len(k) - 1
            while i >= 0:
                translated = translated + k[i]
                i = i - 1
                pass
            print (translated)

the same method is applicable to this one ...
just give a try and drop your questions if there is any, happy coidng season from codelent.

0 comments:

Post a Comment