OSDN Git Service

Updated Python bindings.
authorLoRd_MuldeR <mulder2@gmx.de>
Fri, 25 Mar 2016 18:10:00 +0000 (19:10 +0100)
committerLoRd_MuldeR <mulder2@gmx.de>
Fri, 25 Mar 2016 18:10:00 +0000 (19:10 +0100)
bindings/Python/example/Example.py
bindings/Python/native/src/MHashPy384.cpp
bindings/Python/wrapper/MHashPy384_Wrapper.py

index 53cfca3..3c51fcf 100644 (file)
@@ -36,7 +36,8 @@ def main(argv):
     with MHash384() as digest:
         with open(argv[0], 'rb') as fs:
             for chunk in read_chunks(fs):
-                digest.update(chunk)
+                if not digest.update(chunk):
+                    raise Exception("Something went wrong!")
             print(binascii.hexlify(digest.result()))
 
 if __name__ == "__main__":
index 3b8da7e..f3cad67 100644 (file)
@@ -48,7 +48,7 @@ static PyObject *MHashPy384_Update(PyObject *const self, PyObject *const args)
                                {
                                        const size_t len_val = len ? PyLong_AsSize_t(len) : (total_size - offset_val);
                                        const size_t sum = offset_val + len_val;
-                                       if ((sum >= offset_val) && (sum >= len_val) && (sum < total_size))
+                                       if ((sum >= offset_val) && (sum >= len_val) && (sum <= total_size))
                                        {
                                                reinterpret_cast<mhash::MHash384*>(inst_ptr)->update(reinterpret_cast<uint8_t*>(PyBytes_AsString(data)) + offset_val, len_val);
                                                Py_RETURN_TRUE;
index 15ee067..9318d07 100644 (file)
@@ -27,7 +27,7 @@ class MHash384:
         self.__handle = native.create()
         return self
     def update(self, data):
-        native.update(self.__handle, data)
+        return native.update(self.__handle, data)
     def result(self):
         return native.result(self.__handle)
     def __exit__(self, type, value, traceback):