python - 字节中的语法错误(" ".format(), encoding="utf-8")
问题描述
运行时:
import hashlib
hash1 = hashlib.md5(b'admin:Pentester Academy:asdds').hexdigest()
hash2 = hashlib.md5(b'GET:/lab/webapp/digest/1').hexdigest()
nonce = "526f295f84bcafc67598cd8e760a9cc5"
response_unhashed = (bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
response_md5hashed = hashlib.md5(response_unhashed).hexdigest()
print(response_md5hashed)
我明白这个...
Traceback (most recent call last):
File "C:\Users\Adrian\Desktop\Infosec\Notes\Programming\example.py", line 7
response_unhashed = (bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
^
SyntaxError: invalid syntax
语法错误在哪里?检查了一些 bytes() 和 format() 文档,但找不到任何线索。
解决方案
你可以试试这个:
import hashlib
hash1 = hashlib.md5(b'admin:Pentester Academy:asdds').hexdigest()
hash2 = hashlib.md5(b'GET:/lab/webapp/digest/1').hexdigest()
nonce = "526f295f84bcafc67598cd8e760a9cc5"
response_unhashed = bytes("{}:{}:{}".format(hash1,nonce,hash2), encoding = "utf-8")
response_md5hashed = hashlib.md5(response_unhashed).hexdigest()
print(response_md5hashed)
推荐阅读
- google-sheets - 谷歌表:条件格式以匹配单元格中的错误“#N/A”
- vue.js - 访问特定页面时的 NGINX 404(Azure 应用服务)
- sql - 当前日期减一,日期定义为字符串
- ios - 自定义无限垂直堆叠轮播
- io - 如何使用 ArangoDB 限制存储 IO?
- flutter - 使用 Flutter 在 whatsapp、telegram 和 Signal 中导入贴纸包
- facebook-opengraph - og:image:url 与 og:image 之间的区别
- sockets - 套接字和主循环的 tkinter 问题
- apache-kafka - 无权访问事件中心命名空间内的主题
- python - 是否可以在不使用任何导入的情况下从单词中拆分后缀