<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 16/09/2019 10:38, Andreas Tille
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20190916093849.stchjxhwibsb7ydx@an3as.eu">
      <pre class="moz-quote-pre" wrap="">Hi Peter,

On Sun, Sep 15, 2019 at 02:47:50PM +0100, peter green wrote:
</pre>
      <blockquote type="cite">
        <blockquote type="cite">
          <blockquote type="cite">
            <pre class="moz-quote-pre" wrap="">tmp = rt.encrypt('Cycle{}'.format(pickle.dumps(objSave)))
</pre>
          </blockquote>
          <pre class="moz-quote-pre" wrap="">Thanks to this hint
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">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) )"
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">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. 

</pre>
    </blockquote>
    <p>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.<br>
      <br>
      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.<br>
      <br>
      <code><span class="n">"drotor</span><span class="p">[</span><span
          class="n">i</span><span class="p">]</span> <span class="o">=</span>
        <span class="n">erotor</span><span class="p">[</span><span
          class="n">i</span><span class="p">]</span> <span class="o">=</span>
        <span class="mi">1</span> <span class="o">+</span> <span
          class="mi">2</span><span class="o">*</span><span class="n">rand</span><span
          class="p">(</span><span class="n">i</span><span class="o">/</span><span
          class="mi">2</span><span class="p">)</span> <span class="c1">#
          increment" -> </span></code><code><span class="c1"><code><span
              class="n">"drotor</span><span class="p">[</span><span
              class="n">i</span><span class="p">]</span> <span
              class="o">=</span> <span class="n">erotor</span><span
              class="p">[</span><span class="n">i</span><span class="p">]</span>
            <span class="o">=</span> <span class="mi">1</span> <span
              class="o">+</span> <span class="mi">2</span><span
              class="o">*</span><span class="n">rand</span><span
              class="p">(</span><span class="n">i</span><span class="o">//</span><span
              class="mi">2</span><span class="p">)</span> <span
              class="c1"># increment"<br>
              "</span></code></span></code><code><span class="c1"><code><span
              class="c1"><code><span class="n">x</span> <span class="o">=</span>
                <span class="mi">171</span> <span class="o">*</span> <span
                  class="p">(</span><span class="n">x</span> <span
                  class="o">%</span> <span class="mi">177</span><span
                  class="p">)</span> <span class="o">-</span> <span
                  class="mi">2</span> <span class="o">*</span> <span
                  class="p">(</span><span class="n">x</span><span
                  class="o">/</span><span class="mi">177</span><span
                  class="p">)</span></code>" -> </span></code></span></code><code><span
          class="n">"x</span> <span class="o">=</span> <span
          class="mi">171</span> <span class="o">*</span> <span
          class="p">(</span><span class="n">x</span> <span class="o">%</span>
        <span class="mi">177</span><span class="p">)</span> <span
          class="o">-</span> <span class="mi">2</span> <span class="o">*</span>
        <span class="p">(</span><span class="n">x</span><span class="o">/</span><span
          class="mi">/177</span><span class="p">)"<br>
          "</span></code><code><span class="p"><code><span class="n">y</span>
            <span class="o">=</span> <span class="mi">172</span> <span
              class="o">*</span> <span class="p">(</span><span
              class="n">y</span> <span class="o">%</span> <span
              class="mi">176</span><span class="p">)</span> <span
              class="o">-</span> <span class="mi">35</span> <span
              class="o">*</span> <span class="p">(</span><span
              class="n">y</span><span class="o">/</span><span class="mi">176</span><span
              class="p">)</span></code>" -> "</span></code><code><span
          class="p"><code><span class="p"><code><span class="n">y</span>
                <span class="o">=</span> <span class="mi">172</span> <span
                  class="o">*</span> <span class="p">(</span><span
                  class="n">y</span> <span class="o">%</span> <span
                  class="mi">176</span><span class="p">)</span> <span
                  class="o">-</span> <span class="mi">35</span> <span
                  class="o">*</span> <span class="p">(</span><span
                  class="n">y</span><span class="o">//</span><span
                  class="mi">176</span><span class="p">)</span></code></span></code>"<br>
          "z = 170 * (z % 178) - 63 * (z/178)" -> "z = 170 * (z %
          178) - 63 * (z//178)"</span></code><br>
      <code><span class="c1"><code><span class="c1"></span></code></span></code></p>
    <p><code><span class="c1"><code><span class="c1"><br>
            </span></code></span></code></p>
  </body>
</html>