Skip to content

Instantly share code, notes, and snippets.

@takidog
Last active June 21, 2019 15:23
Show Gist options
  • Save takidog/9aab4414f38ca6125aa25864d3e62720 to your computer and use it in GitHub Desktop.
Save takidog/9aab4414f38ca6125aa25864d3e62720 to your computer and use it in GitHub Desktop.
import execjs
import hashlib
import base64
# import md5
def test():
load_js = execjs.compile(open("md5.js", 'r').read())
test_string = "abcdefg"
js_function_text = load_js.call('base64_md5', test_string)
print("js function result : \n ", js_function_text)
res = base64.b64decode(js_function_text)
print("\nbase64_md5 decode : \n", res)
m = hashlib.md5()
m.update(test_string.encode('utf-8'))
res = m.digest()
print("\npython md5 encode with utf-8 : \n", res)
print("\npython md5 encode to base64 : \n", base64.b64encode(res))
if __name__ == "__main__":
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment