这是indexloc提供的服务,不要输入任何密码
Skip to content

hotwatermorning/PKV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PKV generator and validator

This project provides a key generator and a key validator of PKV (Partial Key Verification).

How to use.

This project can be used as a header only library.

You need to define these macros to use the validator function.

  • HWM_PKV_SUBKEY0_PARAM_A
  • HWM_PKV_SUBKEY0_PARAM_B
  • HWM_PKV_SUBKEY0_PARAM_C
  • HWM_PKV_SUBKEY1_PARAM_A
  • HWM_PKV_SUBKEY1_PARAM_B
  • HWM_PKV_SUBKEY1_PARAM_C
  • HWM_PKV_SUBKEY2_PARAM_A
  • HWM_PKV_SUBKEY2_PARAM_B
  • HWM_PKV_SUBKEY2_PARAM_C
  • HWM_PKV_SUBKEY3_PARAM_A
  • HWM_PKV_SUBKEY3_PARAM_B
  • HWM_PKV_SUBKEY3_PARAM_C
  • HWM_PKV_CHECKSUM_MAGIC_NUMBER_LEFT
  • HWM_PKV_CHECKSUM_MAGIC_NUMBER_RIGHT
  • HWM_PKV_USE_SUBKEY0
  • HWM_PKV_USE_SUBKEY1
  • HWM_PKV_USE_SUBKEY2
  • HWM_PKV_USE_SUBKEY3

If you use CMake to configure your project, it is convenient to use setup_pkv_defines() command in PVK.cmake.sample.

To use the generator function, this macro should also be defined with the value 1.

  • HWM_PKV_ENABLE_KEY_GENERATOR=1

Once these macros are defined, include PKV.h in a source file of your project.

#include <PKV/PKV.h>

And invoke the validator and the generator function like this.

std::vector<std::string> keys;

// generate keys
for(int i = 0; i < 100; ++i) {
    keys.push_back(hwm::PKV::generateKey(i));
}

// validate all keys
for(auto const & key: keys) {
    if(hwm::PKV::isValidKey(key)) {
        std::cout << "Valid key." << std::endl;
    } else {
        std::cout << "Invalid key." << std::endl;
    }
}

Build example apps

Windows:

cd C:¥path¥to¥develo¥PKV
cmake -B build -G "Visual Studio 16 2019" .
cmake --build build

# run generator
.¥build¥example¥generator¥Debug¥pkv-generator

# run validator
.¥build¥example¥generator¥Debug¥pkv-validator

macOS:

cd /path/to/develop/PKV
cmake -B build -G Xcode .
cmake --build build

# run generator
./build/example/generator/Debug/pkv-generator

# run validator
./build/example/validator/Debug/pkv-validator

Acknowledgement

This project is based on juce_pkv_example.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published