小编Bùi*_*Thủ的帖子

PyOTP 生成的代码与 Google Authenticator 生成的代码不匹配

我想在Python中实现Google Authenticator生成的2FA代码

Google Play 上的应用程序 Google Authenticator 可为所需服务生成两步验证。

我已经在我的 Google 帐户上设置了 2FA,他们以“bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa”的形式向我提供了密码,并注明“空格无关紧要”

所以,我在Python中尝试了以下代码,但它不起作用。

在 Google 身份验证器中,我已经选择了“基于时间”

我的计算机上运行下面的脚本的时间与我手机上安装 Google Authenticator 应用程序的时间相同。

import pyotp, base64
totp = pyotp.TOTP( base64.b32encode("bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa") )
print "Current OTP:" + totp.now()
Run Code Online (Sandbox Code Playgroud)

Google Authenticator App 生成的代码与我的代码不匹配。

我究竟做错了什么 ?

python google-authenticator

7
推荐指数
1
解决办法
3370
查看次数

如何防止 Visual Studio 中从 for 循环到 memset() 的自动优化?

我正在开发一个不使用 CRT 的程序,因此,一些使用非常简单的 memset() 实现的第三方喜欢:

char x[10];
for(int i= 0; i< 10; i++) {
  x[i] = '\0';
}
Run Code Online (Sandbox Code Playgroud)

第三方库中有很多此类代码,而且我不喜欢乱搞它,那么,如何防止 Visual Studio 自动从 for 循环转换为 memset() ?

编辑:为什么这是一个问题?由于我的程序不使用CRT,因此,如果Visual Studio自动将for循环转换为memset(),则会导致错误:

Unresolved external symbol _memset
Run Code Online (Sandbox Code Playgroud)

c for-loop memset compiler-optimization visual-studio

5
推荐指数
1
解决办法
1030
查看次数