On 16/09/2019 10:38, Andreas Tille wrote:
Hi Peter,
On Sun, Sep 15, 2019 at 02:47:50PM +0100, peter green wrote:
tmp = rt.encrypt('Cycle{}'.format(pickle.dumps(objSave)))
Thanks to this hint
This hint was *wrong*, it will introduce garbage into the string and the
"rotor" code is clearly designed to work with byte strings, not unicode strings.
Change it to
"tmp=rt.encrypt( b'Cycle'+pickle.dumps(objSave) )"
Thanks a lot for your patience. Unfortunately this is not
yet the final solution:
...
Traceback (most recent call last):
File "/usr/bin/cycle", line 83, in OnCloseWindow
Save_Cycle(cycle.name, cycle.passwd, cycle.file)
File "/usr/share/cycle/save_load.py", line 46, in Save_Cycle
tmp=rt.encrypt( b'Cycle'+pickle.dumps(objSave) )
File "/usr/share/cycle/p_rotor.py", line 63, in encrypt
return self.cryptmore(buf, 0)
File "/usr/share/cycle/p_rotor.py", line 88, in cryptmore
c = rotors[i][c ^ pos[i]]
TypeError: unsupported operand type(s) for ^: 'int' and 'float'
Kind regards
Andreas.
When you get a floating point number where you were expecting an integer that
is probably an issue related to the change in behavior of the division operator
in python 3. In python 2 using the regular division operator on two integers
produces an integer result, but in python 3 it produces a floating point result.
I see a few cases in the p_rotor code where regular division is used in a way
that python2 would interpret it as floored division but python3 would interpret
it as floating point division.
|"drotor[i] = erotor[i] = 1 + 2*rand(i/2) # increment" -> |||"drotor[i] = erotor[i]
= 1 + 2*rand(i//2) # increment"
"|||||x = 171 * (x % 177) - 2 * (x/177)|" -> |||"x = 171 * (x % 177) - 2 *
(x//177)"
"|||y = 172 * (y % 176) - 35 * (y/176)|" -> "||||y = 172 * (y % 176) - 35 *
(y//176)||"
"z = 170 * (z % 178) - 63 * (z/178)" -> "z = 170 * (z % 178) - 63 * (z//178)"|
||||
||
||