我正在尝试比较 encode_base64('test')
到包含 'test' 的 base64 字符串的字符串变量。问题是它永远不会验证!
use MIMI::Base64 qw(encode_base64);
if (encode_base64("test") eq "dGVzdA==")
{
print "true";
}
我是不是忘记了什么?
最佳答案
Here's一个指向 Perlmonks 页面的链接,上面写着“注意 encode_base64() 编码字符串末尾的换行符”。
所以简单的“eq”可能会失败。
要取消换行,请说 encode_base64("test", "")
反而。
关于perl - 为什么 Perl 中的 base64 字符串比较会失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1735774/