Advertisement
foolkiller204

Password Encrypter

Jun 21st, 2023
2,328
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.02 KB | Cybersecurity | 0 0
  1. def program():
  2.     def validation(inp):
  3.         split = inp.split(" ")
  4.         if len(split)==2 and (split[0].lower()=="enc" or split[0].lower()=="dec"):
  5.             return True, split[0].lower(), split[1]
  6.         else:
  7.             return False, "",""
  8.     encryption_syntax = [
  9.         ['a','∞'],
  10.         ['A','8'],
  11.         ['b','`'],
  12.         ['B','{'],
  13.         ['c','/'],
  14.         ['C','('],
  15.         ['d','+'],
  16.         ['D',')'],
  17.         ['e','c'],
  18.         ['E','3'],
  19.         ['f','?'],
  20.         ['F','#'],
  21.         ['g','}'],
  22.         ['G','$'],
  23.         ['h','O'],
  24.         ['H',';'],
  25.         ['i','-'],
  26.         ['I','|'],
  27.         ['j','B'],
  28.         ['J','['],
  29.         ['k','z'],
  30.         ['K','@'],
  31.         ['l','.'],
  32.         ['L','1'],
  33.         ['m','5'],
  34.         ['M','='],
  35.         ['n','<'],
  36.         ['N','A'],
  37.         ['O','0'],
  38.         ['o','*'],
  39.         ['p','%'],
  40.         ['P',']'],
  41.         ['q','Y'],
  42.         ['Q','F'],
  43.         ['r','>'],
  44.         ['R','\\'],#double slash cause its an escape char
  45.         ['s','~'],
  46.         ['S','^'],
  47.         ['t','M'],
  48.         ['T','f'],
  49.         ['u','!'],
  50.         ['U',','],
  51.         ['v','"'],
  52.         ['V','p'],
  53.         ['w','v'],
  54.         ['W','V'],
  55.         ['x',':'],
  56.         ['X',';'],
  57.         ['y','7'],
  58.         ['Y','a'],
  59.         ['z','j'],
  60.         ['Z','9'],
  61.         ['3','i'],
  62.         ['9','&']
  63.                          ]
  64.  
  65.     inp=input()
  66.  
  67.     passed, keyword, password = validation(inp)
  68.  
  69.     if passed:
  70.         def convert(num,num2):
  71.             new_password=""
  72.             i = 0
  73.             for char in password:
  74.                 for char_set in encryption_syntax:
  75.                     if char==char_set[num]:
  76.                         new_password+=char_set[num2]
  77.                         break;
  78.                 i+=1
  79.             return new_password
  80.         if keyword == "enc":
  81.             print(convert(0,1))
  82.         if keyword == "dec":
  83.             print(convert(1,0))
  84.     else:
  85.         print("Invalid Input")
  86.     program()
  87. program()
Tags: cryptography
Advertisement
Comments
  • bluewave41
    1 year
    # text 0.27 KB | 0 0
    1. Why though? This is crazy unsafe and if someone got the result of passing in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' they've just leaked your entire encryption table and reversing it is trivial.
    2.  
    3. Always hash passwords with a known secure algorithm like argon2.
Add Comment
Please, Sign In to add comment
Advertisement