aboutsummaryrefslogtreecommitdiffstats
path: root/sha3sum.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-02-04 06:48:48 +0100
committerMattias Andrée <maandree@operamail.com>2013-02-04 06:48:48 +0100
commit2db068eabc0067244f1add78b4e829014df20d26 (patch)
treeac50905335c59b2561c1c4c749ad90e9ec6763a9 /sha3sum.py
parentsupport for slaxed chunks (diff)
downloadsha3sum-2db068eabc0067244f1add78b4e829014df20d26.tar.gz
sha3sum-2db068eabc0067244f1add78b4e829014df20d26.tar.bz2
sha3sum-2db068eabc0067244f1add78b4e829014df20d26.tar.xz
the java program (does not hash as python, but I think python also got som bug sneaked in)
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'sha3sum.py')
-rwxr-xr-xsha3sum.py48
1 files changed, 26 insertions, 22 deletions
diff --git a/sha3sum.py b/sha3sum.py
index 76de98b..0e9e0dc 100755
--- a/sha3sum.py
+++ b/sha3sum.py
@@ -534,31 +534,31 @@ if __name__ == '__main__':
sys.stderr.buffer.write(('''
SHA-3/Keccak checksum calculator
-USAGE: sha3sum [option...] < file
- sha3sum [option...] file...
+USAGE: sha3sum [option...] < file
+ sha3sum [option...] file...
OPTIONS:
- -r BITRATE
- --bitrate The bitrate to use for SHA-3. (default: %d)
-
- -c CAPACITY
- --capacity The capacity to use for SHA-3. (default: %d)
-
- -w WORDSIZE
- --wordsize The word size to use for SHA-3. (default: %d)
-
- -o OUTPUTSIZE
- --outputsize The output size to use for SHA-3. (default: %d)
-
- -s STATESIZE
- --statesize The state size to use for SHA-3. (default: %d)
-
- -i ITERATIONS
- --iterations The number of hash iterations to run. (default: %d)
+ -r BITRATE
+ --bitrate The bitrate to use for SHA-3. (default: %d)
+
+ -c CAPACITY
+ --capacity The capacity to use for SHA-3. (default: %d)
+
+ -w WORDSIZE
+ --wordsize The word size to use for SHA-3. (default: %d)
+
+ -o OUTPUTSIZE
+ --outputsize The output size to use for SHA-3. (default: %d)
+
+ -s STATESIZE
+ --statesize The state size to use for SHA-3. (default: %d)
+
+ -i ITERATIONS
+ --iterations The number of hash iterations to run. (default: %d)
- -b
- --binary Print the checksum in binary, rather than hexadecimal.
+ -b
+ --binary Print the checksum in binary, rather than hexadecimal.
COPYRIGHT:
@@ -653,7 +653,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
with open(fn, 'rb') as file:
SHA3.initalise(r, c, o)
blksize = os.stat(os.path.realpath(fn)).st_size
- SHA3.update(file.read(blksize))
+ while True:
+ chunk = file.read(blksize)
+ if len(chunk) == 0:
+ break
+ SHA3.update(chunk)
bs = SHA3.digest(file.read())
for _ in range(1, i):
SHA3.initalise(r, c, o)