/usr/share/furiusisomount/filehash.py is in furiusisomount 0.11.3.1~repack1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#This file is part of PyFuriusIsoMount. Copyright 2008 Dean Harris (marcus_furius@hotmail.com)
#
# PyFuriusIsoMount is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyFuriusIsoMount is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyFuriusIsoMount. If not, see <http://www.gnu.org/licenses/>.
import hashlib
import string
import os
from gettext import gettext as _
class checksum():
def __init__(self):
self.hash = _('Calculating, please wait...')
self.progress = 0.0
def hexstr(self, s):
h = string.hexdigits
r = ''
for c in s:
i = ord(c)
r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
return r
def computemd5(self, file, CHUNK=2**16):
self.hash = _('Calculating, please wait...')
self.progress = 0.0
try:
file_stream = open(file, 'rb')
hash = hashlib.md5()
size = os.stat(file).st_size
total = 0
while True:
chunk = file_stream.read(CHUNK)
if not chunk:
break
hash.update(chunk)
total += CHUNK
self.progress = float(total) / float(size)
finally:
file_stream.close( )
self.progress = 1.0
self.hash = self.hexstr(hash.digest())
def computesha1(self, file, CHUNK=2**16):
self.hash = 'Calculating, please wait...'
self.progress = 0.0
try:
file_stream = open(file, 'rb')
hash = hashlib.sha1()
size = os.stat(file).st_size
total = 0
while True:
chunk = file_stream.read(CHUNK)
if not chunk:
break
hash.update(chunk)
total += CHUNK
self.progress = float(total) / float(size)
finally:
file_stream.close( )
self.progress = 1.0
self.hash = self.hexstr(hash.digest())
|