Python:生成MD5值的两种方式

测试环境

  • Python 3.9.12
  • feapder 1.7.9

方案一

from hashlib import md5

print(md5(str('123' + '456').encode('utf8')).hexdigest())

运行结果

e10adc3949ba59abbe56e057f20f883e

方案二

from feapder.utils import tools

print(tools.get_md5('123' + '456'))

运行结果

e10adc3949ba59abbe56e057f20f883e

说明

  • 方案一中的依赖库为Python自带,方案二需要手动安装第三方库feapder
  • 方案二是对方案一的封装。
  • tools中类似的方法还有get_sha1()get_base64()get_uuid()get_hash()

猜你喜欢

转载自blog.csdn.net/qq_34562959/article/details/127372863