1

Trying to build a program that will compute discrete log modulo a prime p. I am attempting to perform this using a meet-in-the-middle approach. Build a hash table like this:

lhs = [powmod(g,i,p) for i in range(2**20)]

And then call this;

with open("temp1.red","w") as f:
    pickle.dump(lhs,f)
    f.close()
    print ("calculate 1/2^20 array")
    lhs = [xgcd(i,p)[1] for i in lhs]

When it hits the dump method it thr5ows a TypeError exception:

Traceback (most recent call last):
  File "C:\Users\lincoln\Desktop\eclipse-standard-luna-R-win32-x86_64\workspace\Python 3\src\Modulo.py", line 150, in <module>
    pickle.dump(lhs,f)
TypeError: must be str, not bytes

I am using Python 3.4. Any ideas?

Richy
  • 417
  • 2
  • 4
  • 10
  • I don't know if this is related to your problem, but you don't need to do `f.close()` if you opened `f` from inside a `with` statement. The closing is done for you automatically. – Kevin Feb 11 '15 at 20:29

0 Answers0