if not forceReadablePassword:
###########################################################
don't do anything by default: the urllib.parse.quote
or cgi.escape calls in commonhtml.py will escape the
password as needed to embed in URL or HTML; the
cgi module undoes escapes automatically for us;
###########################################################
def stringify(old): return old
def unstringify(old): return old
else:
###########################################################
convert encoded string to/from a string of digit chars,
to avoid problems with some special/nonprintable chars,
but still leave the result semi-readable (but encrypted);
some browsers had problems with escaped ampersands, etc.;
###########################################################
separator = '-'
def stringify(old):
new = ''
for char in old:
ascii = str(ord(char))
new = new + separator + ascii # '-ascii-ascii-ascii'
return new
def unstringify(old):
new = ''
for ascii in old.split(separator)[1:]:
new = new + chr(int(ascii))
return new
###############################################################################
encryption schemes: try PyCrypto, then rotor, then simple/custom scheme
###############################################################################
useCrypto = useRotor = True
try:
import Crypto
except:
useCrypto = False
try:
import rotor
except:
useRotor = False
if useCrypto:
#######################################################
use third-party pycrypto package's AES algorithm
assumes pswd has no '\0' on the right: used to pad
change the private key here if you install this
#######################################################
Utility Modules | 1283