I have made a string encryption method, but i can't find out how to make a decryption method. My encryption function is below (in python)
def encrypt(text, key): cmp=["q","w","e","r","t","y","i","u","p","o","s","a","f","d","h","g","k","j","k","l","z","x","c","v","b","n","m","Q","l","E","W","T","R","U","Y","O","I","A","P","D","S","G","F","J","H","L","K","X","Z","V","C","N","B","`","M","2","1","4","3","6","5","8","7","0","9","=","-","!","~","#","@","%","$","&","^","(","*","_",")"," ","+","[","]","\\","{","}","|",",",".","/","<",">","/"] md={} c=0 for id in cmp: md[id]=c c+=1 keyInFigs=0 for char in key: keyInFigs+=md[char] textObj=text textInFigs="" for char in textObj: textInFigs+=str(md[char])+" " textInFigs=textInFigs.removesuffix(" ") output="" for char in textInFigs.split(): output += str(int(char) * keyInFigs) +" " return outputand my decryption algorithm:
def encrypt(text, key): cmp=["q","w","e","r","t","y","i","u","p","o","s","a","f","d","h","g","k","j","k","l","z","x","c","v","b","n","m","Q","l","E","W","T","R","U","Y","O","I","A","P","D","S","G","F","J","H","L","K","X","Z","V","C","N","B","`","M","2","1","4","3","6","5","8","7","0","9","=","-","!","~","#","@","%","$","&","^","(","*","_",")"," ","+","[","]","\\","{","}","|",",",".","/","<",">","/"] md={} c=0 for id in cmp: md[id]=c c+=1 keyInFigs=0 for char in key: keyInFigs+=md[char] textObj=text textInFigs="" for char in textObj: textInFigs+=str(md[char])+" " textInFigs=textInFigs.removesuffix(" ") output="" for char in textInFigs.split(): output += str(int(int(char) / keyInFigs)) return outputThank you for help in advance.