@@ -13,7 +13,7 @@ You should have received a copy of the GNU Affero General Public License
1313along with searx. If not, see < http://www.gnu.org/licenses/ >.
1414
1515(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
16−(C) 2018 by Vaclav Zouzalik
16+(C) 2018, 2020 by Vaclav Zouzalik
1717'''
1818
1919from flask_babel import gettext
@@ -24,7 +24,7 @@ name = "Hash plugin"
2424description = gettext("Converts strings to different hash digests.")
2525default_on = True
2626
27−parser_re = re.compile(b'(md5|sha1|sha224|sha256|sha384|sha512) (.*)', re.I)
27+parser_re = re.compile('(md5|sha1|sha224|sha256|sha384|sha512) (.*)', re.I)
2828
2929
3030def post_search(request, search):
@@ -37,7 +37,6 @@ def post_search(request, search):
3737 return True
3838
3939 function, string = m.groups()
40− function = str(function.decode('UTF-8')) # convert to string for python3
4140 if string.strip().__len__() == 0:
4241 # end if the string is empty
4342 return True
@@ -46,10 +45,10 @@ def post_search(request, search):
4645 f = hashlib.new(function.lower())
4746
4847 # make digest from the given string
49− f.update(string.strip())
50− digest = f.hexdigest()
48+ f.update(string.encode('utf-8').strip())
49+ answer = function + " " + gettext('hash digest') + ": " + f.hexdigest()
5150
5251 # print result
5352 search.result_container.answers.clear()
54− search.result_container.answers.add(function + " " + gettext('hash function') + ": " + digest)
53+ search.result_container.answers['hash'] = { 'answer': answer }
5554 return True