欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

在rMBP上利用Python的onetimepass库实现Google Authenticator Application的效果

发布时间:2023/11/27 53 豆豆
生活随笔 收集整理的这篇文章主要介绍了 在rMBP上利用Python的onetimepass库实现Google Authenticator Application的效果 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
安装onetimepass库
在Mac上最简单的安装方法是
sudo pip install onetimepass
这里我遇到一个问题,参见
http://blog.csdn.net/tao_627/article/details/69499639
解决方法是
pip install --trusted-host pypi.python.org onetimepass


编写Python脚本验证
将下面的脚本复制为~/Applications/onetimepass_demo.py文件
#!/usr/bin/pythonimport onetimepass as otp
my_secret = 'MFRGGZDFMZTWQ2LK'
my_token = otp.get_totp(my_secret)
print my_token

这段代码片段来自onetimepass的GitHub官网

https://github.com/tadeck/onetimepass

这里my_secret是你注册完Google Authenticator Application后得到的密钥,运维会给你

运行下面的命令

python onetimepass_demp.py

经过测试,发现这个结果和Android手机应用Google Authenticator Application上是一样的


总结

以上是生活随笔为你收集整理的在rMBP上利用Python的onetimepass库实现Google Authenticator Application的效果的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。