本文整理汇总了C++中SecureBinaryData::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ SecureBinaryData::resize方法的具体用法?C++ SecureBinaryData::resize怎么用?C++ SecureBinaryData::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecureBinaryData
的用法示例。
在下文中一共展示了SecureBinaryData::resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestCrypto
void TestCrypto(void)
{
SecureBinaryData a("aaaaaaaaaa");
SecureBinaryData b; b.resize(5);
SecureBinaryData c; c.resize(0);
a.copyFrom(b);
b.copyFrom(c);
c.copyFrom(a);
a.resize(0);
b = a;
SecureBinaryData d(a);
cout << "a=" << a.toHexStr() << endl;
cout << "b=" << b.toHexStr() << endl;
cout << "c=" << c.toHexStr() << endl;
cout << "d=" << d.toHexStr() << endl;
SecureBinaryData e("eeeeeeeeeeeeeeee");
SecureBinaryData f("ffffffff");
SecureBinaryData g(0);
e = g.copy();
e = f.copy();
cout << "e=" << e.toHexStr() << endl;
cout << "f=" << f.toHexStr() << endl;
cout << "g=" << g.toHexStr() << endl;
/////////////////////////////////////////////////////////////////////////////
// Start Key-Derivation-Function (KDF) Tests.
// ROMIX is the provably memory-hard (GPU-resistent) algorithm proposed by
// Colin Percival, who is the creator of Scrypt.
cout << endl << endl;
cout << "Executing Key-Derivation-Function (KDF) tests" << endl;
KdfRomix kdf;
kdf.computeKdfParams();
kdf.printKdfParams();
SecureBinaryData passwd1("This is my first password");
SecureBinaryData passwd2("This is my first password.");
SecureBinaryData passwd3("This is my first password");
SecureBinaryData key;
cout << " Password1: '" << passwd1.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd1);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
cout << " Password2: '" << passwd2.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd2);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
cout << " Password1: '" << passwd3.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd3);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
/////////////////////////////////////////////////////////////////////////////
cout << "Executing KDF tests with longer compute time" << endl;
kdf.computeKdfParams(1.0);
kdf.printKdfParams();
cout << " Password1: '" << passwd1.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd1);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
cout << " Password2: '" << passwd2.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd2);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
cout << " Password1: '" << passwd3.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd3);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
/////////////////////////////////////////////////////////////////////////////
cout << "Executing KDF tests with limited memory target" << endl;
kdf.computeKdfParams(1.0, 256*1024);
kdf.printKdfParams();
cout << " Password1: '" << passwd1.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd1);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
cout << " Password2: '" << passwd2.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd2);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
cout << " Password1: '" << passwd3.toBinStr() << "'" << endl;
key = kdf.DeriveKey(passwd3);
cout << " MasterKey: '" << key.toHexStr() << endl << endl;
/////////////////////////////////////////////////////////////////////////////
cout << "KDF with min memory requirement (1 kB)" << endl;
kdf.computeKdfParams(1.0, 0);
kdf.printKdfParams();
cout << " Password1: '" << passwd1.toBinStr() << "'" << endl;
//.........这里部分代码省略.........