comparison shasum.py @ 8:048b97213a23

Change the default algorithm to SHA1 to be compatible with Perl's shasum
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 04 Dec 2020 15:18:40 +0100
parents 47b4c98e4d40
children 81f28bf89c26
comparison
equal deleted inserted replaced
7:47b4c98e4d40 8:048b97213a23
26 aparser = argparse.ArgumentParser( 26 aparser = argparse.ArgumentParser(
27 description="Python implementation of shasum", 27 description="Python implementation of shasum",
28 fromfile_prefix_chars='@') 28 fromfile_prefix_chars='@')
29 aparser.add_argument( 29 aparser.add_argument(
30 "--algorithm", "-a", action="store", type=argv2algo, 30 "--algorithm", "-a", action="store", type=argv2algo,
31 help="1, 224, 256 (default), 384, 512, 3-224, 3-256, 3-384, 3-512, blake2b, blake2s, md5") 31 help="1 (default), 224, 256, 384, 512, 3-224, 3-256, 3-384, 3-512, blake2b, blake2s, md5")
32 aparser.add_argument( 32 aparser.add_argument(
33 "--binary", "-b", action="store_false", dest="text_mode", default=False, 33 "--binary", "-b", action="store_false", dest="text_mode", default=False,
34 help="read in binary mode (default)") 34 help="read in binary mode (default)")
35 aparser.add_argument( 35 aparser.add_argument(
36 "--bsd", "-B", action="store_true", 36 "--bsd", "-B", action="store_true",
46 if opts.text_mode: 46 if opts.text_mode:
47 print("ERROR: text mode not supported", file=sys.stderr) 47 print("ERROR: text mode not supported", file=sys.stderr)
48 sys.exit(78) # :manpage:`sysexits(3)` EX_CONFIG 48 sys.exit(78) # :manpage:`sysexits(3)` EX_CONFIG
49 49
50 if not opts.algorithm: 50 if not opts.algorithm:
51 opts.algorithm = argv2algo("256") 51 opts.algorithm = argv2algo("1")
52 52
53 if opts.bsd: 53 if opts.bsd:
54 out = out_bsd 54 out = out_bsd
55 else: 55 else:
56 out = out_std 56 out = out_std