diff options
author | ng0 <ng0@n0.is> | 2019-02-12 10:59:44 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-02-12 10:59:44 +0000 |
commit | 551ed5af91446dd1352adc03461b2873ba21c3fa (patch) | |
tree | fc3d3eee50084254d4e29ed93f856a665cfbb6d0 /contrib/scripts/gnunet-chk.py.in | |
parent | db602e98ebd0de54c4948a0978110c8371587ab6 (diff) | |
download | gnunet-551ed5af91446dd1352adc03461b2873ba21c3fa.tar.gz gnunet-551ed5af91446dd1352adc03461b2873ba21c3fa.zip |
util: futurize contrib/scripts/gnunet-chk
Signed-off-by: ng0 <ng0@n0.is>
Diffstat (limited to 'contrib/scripts/gnunet-chk.py.in')
-rwxr-xr-x | contrib/scripts/gnunet-chk.py.in | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/contrib/scripts/gnunet-chk.py.in b/contrib/scripts/gnunet-chk.py.in index c60211556..1f5a0726c 100755 --- a/contrib/scripts/gnunet-chk.py.in +++ b/contrib/scripts/gnunet-chk.py.in | |||
@@ -21,6 +21,12 @@ | |||
21 | # Brief: Computes GNUNET style Content Hash Key for a given file | 21 | # Brief: Computes GNUNET style Content Hash Key for a given file |
22 | # Author: Sree Harsha Totakura | 22 | # Author: Sree Harsha Totakura |
23 | 23 | ||
24 | from __future__ import print_function | ||
25 | from __future__ import division | ||
26 | from builtins import str | ||
27 | from builtins import range | ||
28 | from past.utils import old_div | ||
29 | from builtins import object | ||
24 | from hashlib import sha512 | 30 | from hashlib import sha512 |
25 | import logging | 31 | import logging |
26 | import os | 32 | import os |
@@ -90,7 +96,7 @@ def sha512_hash(data): | |||
90 | return hash_obj.digest() | 96 | return hash_obj.digest() |
91 | 97 | ||
92 | 98 | ||
93 | class AESKey: | 99 | class AESKey(object): |
94 | """Class for AES Keys. Contains the main key and the initialization | 100 | """Class for AES Keys. Contains the main key and the initialization |
95 | vector. """ | 101 | vector. """ |
96 | 102 | ||
@@ -177,7 +183,7 @@ def aes_decrypt(aes_key, data): | |||
177 | return ptext | 183 | return ptext |
178 | 184 | ||
179 | 185 | ||
180 | class Chk: | 186 | class Chk(object): |
181 | """Class for the content hash key.""" | 187 | """Class for the content hash key.""" |
182 | key = None | 188 | key = None |
183 | query = None | 189 | query = None |
@@ -248,7 +254,7 @@ def compute_chk_offset_(depth, end_offset): | |||
248 | bds = compute_tree_size_(depth) | 254 | bds = compute_tree_size_(depth) |
249 | if (depth > 0): | 255 | if (depth > 0): |
250 | end_offset -= 1 | 256 | end_offset -= 1 |
251 | ret = end_offset / bds | 257 | ret = old_div(end_offset, bds) |
252 | return ret % CHK_PER_INODE | 258 | return ret % CHK_PER_INODE |
253 | 259 | ||
254 | 260 | ||
@@ -272,7 +278,7 @@ def compute_iblock_size_(depth, offset): | |||
272 | ret = CHK_PER_INODE | 278 | ret = CHK_PER_INODE |
273 | else: | 279 | else: |
274 | bds /= CHK_PER_INODE | 280 | bds /= CHK_PER_INODE |
275 | ret = mod / bds | 281 | ret = old_div(mod, bds) |
276 | if (mod % bds) is not 0: | 282 | if (mod % bds) is not 0: |
277 | ret += 1 | 283 | ret += 1 |
278 | return ret | 284 | return ret |