Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def phraseencrypt(what, phrase): # accepts to arguments a string to enceypt and some tex to tncrypt it with.
- key = [] # create a list to store the phrase to encrypt with.
- for char in phrase: #for loop to itirate through each charcter in the tet stored as prhrase (what to encrypt with)
- key.append(ord(char)) # convert letter to ascii number and apend it to the list key. repeat for all letters
- result = "" # variable ued to append the end result to
- indexkey = 0 # used to keep track of which letter up to in the phrase encryption
- for i in what: # for every letter in the text the user wants encrypting
- i = ord(i) # convert letter to ascii number
- if indexkey == len(phrase): # test to see that the indexkey (place in the llist) is not over the amount of letters that are in it.
- indexkey = 0 # if previouse if statment is true then reset it to 0
- for num in range(1, key[indexkey]+1): # for every number inbtween 1 and the key. Since i store the index of the list in a varibale i can then call the letter that i am up to. +1 to fix bug/error
- if i < 1: # if i is less than 1 then then reset to 127
- i = 127
- i -= 1 # take away one from i (change shift of letter)
- result+= chr(i) # convert ascii number back to letter
- indexkey+=1 # append to string
- return result # return the result
- def hashPassword(password):
- global data
- passwordlen = len(password)
- run = 0
- type = 0
- try:
- hashAmount = data['settings']['hashAmount'] * passwordlen
- except:
- hashAmount = 100
- while run != hashAmount:
- password = str(password).encode('utf-8')
- if type == 0:
- password = hashlib.md5(password).hexdigest() * passwordlen
- elif type == 1:
- password = hashlib.sha1(password).hexdigest() * passwordlen
- elif type == 2:
- password = hashlib.sha224(password).hexdigest() * passwordlen
- elif type == 3:
- password = hashlib.sha256(password).hexdigest() * passwordlen
- elif type == 4:
- password = hashlib.sha384(password).hexdigest() * passwordlen
- elif type == 5:
- password = hashlib.sha512(password).hexdigest() * passwordlen
- elif type == 6:
- type = 0
- run += 1
- type += 1
- return phraseencrypt(str(password), str(password))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement