WIP: Quick and dirty python3 port

This commit is contained in:
Hector Martin
2021-03-17 23:53:31 +09:00
parent a8e5f6c0f7
commit cad274a7fb
41 changed files with 2399 additions and 2387 deletions

View File

@@ -1,33 +1,33 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import sys, os
import pywii as wii
if len(sys.argv) != 2:
print "Usage: %s keyfile.priv"%sys.argv[0]
print("Usage: %s keyfile.priv"%sys.argv[0])
sys.exit(1)
print "Generating private key..."
print("Generating private key...")
k = wii.ec.gen_priv_key()
print "Private key:"
print("Private key:")
pk = k.encode('hex')
print "K =",pk[:30]
print " ",pk[30:]
print("K =",pk[:30])
print(" ",pk[30:])
print
print "Corresponding public key:"
print()
print("Corresponding public key:")
q = wii.ec.priv_to_pub(k)
pq = q.encode('hex')
print "X =",pq[:30]
print " ",pq[30:60]
print "Y =",pq[60:90]
print " ",pq[90:]
print("X =",pq[:30])
print(" ",pq[30:60])
print("Y =",pq[60:90])
print(" ",pq[90:])
fd = open(sys.argv[1],"wb")
os.fchmod(fd.fileno(), 0o600)
fd.write(k)
fd.close()
print "Saved private key to %s"%sys.argv[1]
print("Saved private key to %s"%sys.argv[1])