kryptographi und programmieren
Verfasst: Freitag 2. Februar 2018, 01:43
Hallo Leute,
ich studiere Kryptographi und probiere die ganze Zeit mich in python 3.6.3 aus.
Ich habe eine Rechnung aufgebaut die einfach nicht funktionieren will. Da ich nicht so viel Erfahrung im programmieren habe wollte ich mal die Programmierer fragen ob sie das Programm so schreiben würden oder etwas verändern würden. Das Programm macht mir alles bis zur line 16... Dann hängt er sich auf und ich muss mit Strg + c abbrechen. Wo liegt der Fehler, kann jemand mir helfen?
Wäre würden jeden Vorschlag dankbar..... Gruß vinny
>>> def pow_mod(x, y, z):
... "Calculate (x ** y) % z efficiently."
... number = 1
... while y:
... if y & 1:
... number = number * x % z
... y >>= 1
... x = x * x % z
... if y % 2 != y_parity:
... y = -y % p
... return number
...
>>> p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
>>> compressed_key = '0207843cb94c2398d41b34870d23d09143fab3d9014fc62eedd766fc54d8281b19'
>>> y_parity = int(compressed_key[:2]) - 2
>>> x = int(compressed_key[2:], 16)
>>> a = (pow_mod(x, 3, p) + 7) % p
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in pow_mod
KeyboardInterrupt
>>> y = (pow_mod(a, (p+1)//4, p)
... uncompressed_key = '04{:x}{:x}'.format(x, y)
File "<stdin>", line 2
uncompressed_key = '04{:x}{:x}'.format(x, y)
^
SyntaxError: invalid syntax
>>> print(uncompressed key)
File "<stdin>", line 1
print(uncompressed key)
^
SyntaxError: invalid syntax
ich studiere Kryptographi und probiere die ganze Zeit mich in python 3.6.3 aus.
Ich habe eine Rechnung aufgebaut die einfach nicht funktionieren will. Da ich nicht so viel Erfahrung im programmieren habe wollte ich mal die Programmierer fragen ob sie das Programm so schreiben würden oder etwas verändern würden. Das Programm macht mir alles bis zur line 16... Dann hängt er sich auf und ich muss mit Strg + c abbrechen. Wo liegt der Fehler, kann jemand mir helfen?
Wäre würden jeden Vorschlag dankbar..... Gruß vinny
>>> def pow_mod(x, y, z):
... "Calculate (x ** y) % z efficiently."
... number = 1
... while y:
... if y & 1:
... number = number * x % z
... y >>= 1
... x = x * x % z
... if y % 2 != y_parity:
... y = -y % p
... return number
...
>>> p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
>>> compressed_key = '0207843cb94c2398d41b34870d23d09143fab3d9014fc62eedd766fc54d8281b19'
>>> y_parity = int(compressed_key[:2]) - 2
>>> x = int(compressed_key[2:], 16)
>>> a = (pow_mod(x, 3, p) + 7) % p
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in pow_mod
KeyboardInterrupt
>>> y = (pow_mod(a, (p+1)//4, p)
... uncompressed_key = '04{:x}{:x}'.format(x, y)
File "<stdin>", line 2
uncompressed_key = '04{:x}{:x}'.format(x, y)
^
SyntaxError: invalid syntax
>>> print(uncompressed key)
File "<stdin>", line 1
print(uncompressed key)
^
SyntaxError: invalid syntax