将简单的PHP代码转换为python

weixin_38085383 2019-09-12 12:36:12
我想将我的PHP代码转换为python代码.可能吗 $secret = 'segredo'; // To make the hash more difficult to reproduce. $path = '/p/files/top_secret.pdf'; // This is the file to send to the user. $expire = 1096891200; // At which point in time the file should expire. time() + x; would be the usual usage. $md5 = base64_encode(md5($secret . $path . $expire, true)); // Using binary hashing.`$md5 = strtr($md5, '+/', '-_'); // + and / are considered special characters in URLs, see the wikipedia page linked in references. $md5 = str_replace('=', '', $md5); // When used in query parameters the base64 padding character is considered special. 我想将上面的PHP代码转换为python.是否存在一些转换工具? 此代码是nginx HttpSecureLinkModule的简单唯一url生成器.
...全文
673 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38085883 2019-09-12
  • 打赏
  • 举报
回复
import hashlib secret, path, expire = 'segredo', '/p/files/top_secret.pdf', 1096891200 md5 = hashlib.md5(secret + path + str(expire)).digest().encode('base64').strip('\n=')

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧