本文整理汇总了C++中SecretKey::getBase58Seed方法的典型用法代码示例。如果您正苦于以下问题:C++ SecretKey::getBase58Seed方法的具体用法?C++ SecretKey::getBase58Seed怎么用?C++ SecretKey::getBase58Seed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecretKey
的用法示例。
在下文中一共展示了SecretKey::getBase58Seed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOG
static std::map<std::vector<uint8_t>, std::string> hexTestVectors = {
{{}, ""},
{{0x72}, "72"},
{{0x54, 0x4c}, "544c"},
{{0x34, 0x75, 0x52, 0x45, 0x34, 0x75}, "347552453475"},
{{0x4f, 0x46, 0x79, 0x58, 0x43, 0x6d, 0x68, 0x37, 0x51},
"4f467958436d683751"}};
TEST_CASE("random", "[crypto]")
{
SecretKey k1 = SecretKey::random();
SecretKey k2 = SecretKey::random();
LOG(DEBUG) << "k1: " << k1.getBase58Seed();
LOG(DEBUG) << "k2: " << k2.getBase58Seed();
CHECK(k1.getBase58Seed() != k2.getBase58Seed());
}
TEST_CASE("hex tests", "[crypto]")
{
// Do some fixed test vectors.
for (auto const& pair : hexTestVectors)
{
LOG(DEBUG) << "fixed test vector hex: \"" << pair.second << "\"";
auto enc = binToHex(pair.first);
CHECK(enc.size() == pair.second.size());
CHECK(enc == pair.second);
auto dec = hexToBin(pair.second);
CHECK(pair.first == dec);
示例2: cfgFile
int
main(int argc, char* const* argv)
{
using namespace stellar;
sodium_init();
Logging::init();
std::string cfgFile("stellar-core.cfg");
std::string command;
el::Level logLevel = el::Level::Fatal;
std::vector<char*> rest;
bool newNetwork = false;
bool newDB = false;
std::vector<std::string> newHistories;
std::vector<std::string> metrics;
int opt;
while ((opt = getopt_long_only(argc, argv, "", stellar_core_options,
nullptr)) != -1)
{
switch (opt)
{
case OPT_TEST:
{
rest.push_back(*argv);
rest.insert(++rest.begin(), argv + optind, argv + argc);
return test(static_cast<int>(rest.size()), &rest[0], logLevel, metrics);
}
case OPT_CONF:
cfgFile = std::string(optarg);
break;
case OPT_CMD:
command = optarg;
rest.insert(rest.begin(), argv + optind, argv + argc);
break;
case OPT_VERSION:
std::cout << STELLAR_CORE_VERSION;
return 0;
case OPT_FORCESCP:
newNetwork = true;
break;
case OPT_METRIC:
metrics.push_back(std::string(optarg));
break;
case OPT_NEWDB:
newDB = true;
break;
case OPT_NEWHIST:
newHistories.push_back(std::string(optarg));
break;
case OPT_LOGLEVEL:
logLevel = Logging::getLLfromString(std::string(optarg));
break;
case OPT_GENSEED:
{
SecretKey key = SecretKey::random();
std::cout << "Secret seed: " << key.getBase58Seed() << std::endl;
std::cout << "Public: " << key.getBase58Public() << std::endl;
return 0;
}
default:
usage(0);
return 0;
}
}
Config cfg;
try
{
if (fs::exists(cfgFile))
{
cfg.load(cfgFile);
Logging::setLoggingToFile(cfg.LOG_FILE_PATH);
}
else
{
LOG(WARNING) << "No config file " << cfgFile << " found";
cfgFile = ":default-settings:";
}
Logging::setLogLevel(logLevel, nullptr);
cfg.REBUILD_DB = newDB;
cfg.START_NEW_NETWORK = newNetwork;
cfg.REPORT_METRICS = metrics;
if (command.size())
{
sendCommand(command, rest, cfg.HTTP_PORT);
return 0;
}
else if (newNetwork || newDB)
{
if (newDB)
initializeDatabase(cfg);
if (newNetwork)
setForceSCPFlag(cfg);
return 0;
}
//.........这里部分代码省略.........