[U-Boot] [PATCH 6/8] test/py: add various utility code
Stephen Warren
swarren at wwwdotorg.org
Fri Jan 22 17:49:23 CET 2016
On 01/21/2016 08:36 PM, Simon Glass wrote:
> Hi Stephen,
>
> On 20 January 2016 at 15:15, Stephen Warren <swarren at wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren at nvidia.com>
>>
>> Add various common utility functions. These will be used by a forthcoming
>> re-written UMS test, and a brand-new DFU test.
>> diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
>> +def md5sum_data(data):
>> + '''Calculate the MD5 hash of some data.
>> +
>> + Args:
>> + data: The data to hash.
>> +
>> + Returns:
>> + The hash of the data, as a binary string.
>> + '''
>> +
>> + h = hashlib.md5()
>> + h.update(data)
>> + return h.digest()
>
> Or just:
>
> return hashlib.md5().update(data).digest()
I was going to do that, but it doesn't look like update() returns the
hash object, so I can't chain at least the .digest() call together, so I
may as well leave it as-is.
More information about the U-Boot
mailing list