我尝试使用pyDes和Crypto.Cipher.DES模块实现DES算法.我发现了一个问题,当我用82514145密钥加密然后解密密码93505044我可以检索解密的文本.我发现256个键表现得像这样.这违反了密码学.我的代码如下:
from Crypto.Cipher import DES
plain_text = 'asdfghij'
print 'plain Text: ', plain_text
des = DES.new('82514145', DES.MODE_ECB)
cipher_text = des.encrypt(plain_text)
print 'the cipher text is ', cipher_text
des = DES.new('93505044', DES.MODE_ECB)
print 'the decrypted text is: ', des.decrypt(cipher_text)
Run Code Online (Sandbox Code Playgroud)
输出是:
plain Text: asdfghij
the cipher text is @?Z????
the decrypted text is: asdfghij
Run Code Online (Sandbox Code Playgroud)
我的工作有什么不对吗?我也用pyDes得到了相同的结果.
我正在尝试使用STL堆栈来解决我希望显示堆栈元素的问题。但我没有找到任何有效的方法来显示而不弹出每个元素。
请参考以下代码:
#define mPtr (static_cast<Dog*> (new(Animal)))
class Animal{
public:
virtual void talk(){cout<<"A";}
};
class Dog:public Animal{
int test;
public:
void talk(){bark();}
void bark(){
test=0;cout<<test;
}
};
int main() {
mPtr->talk();
mPtr->bark();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
A0
Run Code Online (Sandbox Code Playgroud)
基类talk()正在执行是有效还是未定义的行为?