From 7d0cad0e665f61da63823ec5ec6fb0c9ff0c2e8b Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 16 May 2019 08:02:20 +0200 Subject: [PATCH] sha1_short: support bytes and str --- osclib/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osclib/util.py b/osclib/util.py index c6164da8..e2ca3f60 100644 --- a/osclib/util.py +++ b/osclib/util.py @@ -159,4 +159,7 @@ def sha1_short(data): if isinstance(data, list): data = '::'.join(data) - return hashlib.sha1(data.encode('utf-8')).hexdigest()[:7] + if isinstance(data, str): + data = data.encode('utf-8') + + return hashlib.sha1(data).hexdigest()[:7]