{ "i2n" : PDTCRYPT_SCRYPT_INTRANATOR
, "params" : PDTCRYPT_SCRYPT_PARAMETERS }
+PDTCRYPT_TT_COLUMNS = 80 # assume standard terminal
class PDTDecryptionError (Exception):
"""Decryption failed."""
print (out)
+def noise_output_candidates (cands, indent=8, cols=PDTCRYPT_TT_COLUMNS):
+ """
+ Print a list of offsets without garbling the terminal too much.
+
+ The indent is counted from column zero; if it is wide enough, the “PDT: ”
+ marker will be prepended, considered part of the indentation.
+ """
+ wd = cols - 1
+ nc = len (cands)
+ idt = " " * indent if indent < 5 else "PDT: " + " " * (indent - 5)
+ line = idt
+ lpos = indent
+ sep = ","
+ lsep = len (sep)
+ init = True # prevent leading separator
+
+ if indent >= wd:
+ raise ValueError ("the requested indentation exceeds the line "
+ "width by %d" % (indent - wd))
+
+ for n in cands:
+ ns = "%d" % n
+ lns = len (ns)
+ if init is False:
+ line += sep
+ lpos += lsep
+
+ lpos += lns
+ if lpos > wd: # line break
+ noise (line)
+ line = idt
+ lpos = indent + lns
+ elif init is True:
+ init = False
+ else: # space
+ line += ' '
+ lpos += 1
+
+ line += ns
+
+ if lpos != indent:
+ noise (line)
+
+
def mode_scan (pw, fname, nacl=None):
"""
Dissect a binary file, looking for PDTCRYPT headers and objects.
"headers; giving up.")
return -1
if PDTCRYPT_VERBOSE is True:
- noise ("PDT: scan complete: found %d candidates" % len (cands))
+ noise ("PDT: scan complete: found %d candidates:" % len (cands))
+ noise_output_candidates (cands)
finally:
os.close (fd)