Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Description:
- #Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently they can be #guessed due to common cultural references. You can get your passphrases stronger by different means. One is the following:
- #choose a text in capital letters including or not digits and non alphabetic characters,
- #shift each letter by a given number but the transformed letter must be a letter (circular shift),
- #replace each digit by its complement to 9,
- #keep such as non alphabetic and non digit characters,
- #downcase each letter in odd position, upcase each letter in even position (the first character is in position 0),
- #reverse the whole result.
- #Example:
- #your text: "BORN IN 2015!", shift 1
- #1 + 2 + 3 -> "CPSO JO 7984!"
- #4 "CpSo jO 7984!"
- #5 "!4897 Oj oSpC"
- #With longer passphrases it's better to have a small and easy program. Would you write it?
- #https://en.wikipedia.org/wiki/Passphrase
- def play_pass(s, n):
- x = 'abcdefghijklmnopqrstuvwxyz'
- index_ = 0
- total = ''
- for i in range(len(s)):
- if s[i].isalpha():
- index_ = x.index(s[i].lower()) + n
- while index_ > 25 or index_ < 0:
- index_ = abs(26 - abs(index_))
- if i % 2 == 0:
- total += x[index_].upper()
- else:
- total += x[index_].lower()
- elif s[i].isdigit():
- index_ = abs(9 - int(s[i]))
- total += str(index_)
- else:
- total += s[i]
- return total[::-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement