b7fb0630f2c466412337d25d2e611eeef7bc381b,ciphers/caesar_cipher.py,,encrypt,#Any#Any#,1

Before Change

def encrypt(strng, key):
    encrypted = ""
    for x in strng:
        indx = (ord(x) + key) % 256
        if indx > 126:
            indx = indx - 95
        encrypted = encrypted + chr(indx)
    return encrypted


def decrypt(strng, key):

After Change

def encrypt(input_string: str, key: int) -> str:
    result = ""
    for x in input_string:
        if not x.isalpha():
            result += x
        elif x.isupper():
            result += chr((ord(x) + key - 65) % 26 + 65)
        elif x.islower():
            result += chr((ord(x) + key - 97) % 26 + 97)
    return result


def decrypt(input_string: str, key: int) -> str:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: TheAlgorithms/Python
Commit Name: b7fb0630f2c466412337d25d2e611eeef7bc381b
Time: 2019-10-17
Author: 33547678+yuriimchg@users.noreply.github.com
File Name: ciphers/caesar_cipher.py
Class Name:
Method Name: encrypt


Project Name: commonsense/conceptnet5
Commit Name: b269b5dadd538b918b86efbc9b791d0baa855563
Time: 2017-04-10
Author: rob@luminoso.com
File Name: conceptnet5/vectors/query.py
Class Name: VectorSpaceWrapper
Method Name: index_prefix_range


Project Name: TheAlgorithms/Python
Commit Name: b7fb0630f2c466412337d25d2e611eeef7bc381b
Time: 2019-10-17
Author: 33547678+yuriimchg@users.noreply.github.com
File Name: ciphers/caesar_cipher.py
Class Name:
Method Name: decrypt