mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-22 17:29:56 +06:00
Fix standalone scripts
This commit is contained in:
parent
53c1d76224
commit
d767857f16
@ -217,8 +217,8 @@ def makeSerial(random):
|
|||||||
|
|
||||||
sha_out = hashlib.sha1(dataToHash.encode('latin-1')).hexdigest().lower()
|
sha_out = hashlib.sha1(dataToHash.encode('latin-1')).hexdigest().lower()
|
||||||
else:
|
else:
|
||||||
import binascii
|
# SHA1 of a bunch of random bytes
|
||||||
sha_out = binascii.hexlify(Random.get_random_bytes(20)).lower()
|
sha_out = hashlib.sha1(Random.get_random_bytes(256)).hexdigest().lower()
|
||||||
|
|
||||||
return sha_out
|
return sha_out
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ class TestAdobe(unittest.TestCase):
|
|||||||
self.assertEqual((len(libadobe.makeSerial(False))), 40, "SHA1 hash for device serial invalid (device-based)")
|
self.assertEqual((len(libadobe.makeSerial(False))), 40, "SHA1 hash for device serial invalid (device-based)")
|
||||||
self.assertEqual((len(libadobe.makeSerial(True))), 40, "SHA1 hash for device serial invalid (random)")
|
self.assertEqual((len(libadobe.makeSerial(True))), 40, "SHA1 hash for device serial invalid (random)")
|
||||||
self.assertEqual(libadobe.makeSerial(False), libadobe.makeSerial(False), "Two non-random serials not identical")
|
self.assertEqual(libadobe.makeSerial(False), libadobe.makeSerial(False), "Two non-random serials not identical")
|
||||||
|
self.assertNotEqual(libadobe.makeSerial(True), libadobe.makeSerial(True), "Two random serials are identical ...")
|
||||||
|
|
||||||
|
self.assertIsInstance(libadobe.makeSerial(True), str, "Serial must be a string, not bytes!")
|
||||||
|
self.assertIsInstance(libadobe.makeSerial(False), str, "Serial must be a string, not bytes!")
|
||||||
|
|
||||||
def test_fingerprintGeneration(self):
|
def test_fingerprintGeneration(self):
|
||||||
'''Check if fingerprint generation works'''
|
'''Check if fingerprint generation works'''
|
||||||
|
Loading…
Reference in New Issue
Block a user