我创建了一个将字母转换为数字的函数(a = 1,b = 2等等)然后我对它们做了这个等式:
b^(a / (b/2))
b = letter being translated
a = previous letter (or if b is the first letter, a = len(string)
例如,以下是翻译字母'e'的方法:
'Hello' = [34, 5, 12, 12, 15]
5^(34 / (5/2)) = 3206210698.73506
以下是我用来执行此操作的代码:
alphabet = {
'H' : 34,
'e' : 5,
'l' : 12,
'o' : 15,
}
entry = "Hello"
password = []
hashed = []
firstNumber = True
lengthPower = len(entry)
counter = 0
for letter in entry:
key = alphabet[letter]
password.append(key)
for number in password:
if firstNumber:
powered = number ** lengthPower
lastNumber = number
firstNumber = False
else:
powered = number ** (password[counter]/(number/2))
lastNumber = number
counter += 1
hashed.append(powered)
但我怎样才能扭转这种行为呢? '3206210698.73506'回到5('e')?
b^(34 / (b/2)) = 3206210698.73506
答案 0 :(得分:0)
y = x ^ n
,x = y ^ (1/n)
。请参阅this或谷歌'逆功率'。所以在你的情况下,这将指导你。
n = 34/(5/2)
y = pow(5, n) # 3206210698.7350655
x = int(pow(y, 1/n)) # 5