##// END OF EJS Templates
Throw UsageError instead of ValueError.
Stefan van der Walt -
Show More
@@ -6,6 +6,8 b' import hashlib'
6 import random
6 import random
7 import getpass
7 import getpass
8
8
9 from IPython.core.error import UsageError
10
9 # Length of the salt in nr of hex chars, which implies salt_len * 4
11 # Length of the salt in nr of hex chars, which implies salt_len * 4
10 # bits of randomness.
12 # bits of randomness.
11 salt_len = 12
13 salt_len = 12
@@ -46,7 +48,7 b" def passwd(passphrase=None, algorithm='sha1'):"
46 else:
48 else:
47 print('Passwords do not match.')
49 print('Passwords do not match.')
48 else:
50 else:
49 raise ValueError('No matching passwords found. Giving up.')
51 raise UsageError('No matching passwords found. Giving up.')
50
52
51 h = hashlib.new(algorithm)
53 h = hashlib.new(algorithm)
52 salt = ('%0' + str(salt_len) + 'x') % random.getrandbits(4 * salt_len)
54 salt = ('%0' + str(salt_len) + 'x') % random.getrandbits(4 * salt_len)
General Comments 0
You need to be logged in to leave comments. Login now