use GNU-style options
Signed-off-by: Double Sine <xiao_ai_yu@live.cn>
This commit is contained in:
parent
5fb7520199
commit
7633988dce
|
|
@ -108,23 +108,23 @@
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage:
|
Usage:
|
||||||
navicat-keygen <-bin|-text> [-adv] <RSA-2048 Private Key File>
|
navicat-keygen <--bin|-text> [--adv] <RSA-2048 private key file>
|
||||||
|
|
||||||
<-bin|-text> Specify "-bin" to generate "license_file" used by Navicat 11.
|
<--bin|--text> Specify "--bin" to generate "license_file" used by Navicat 11.
|
||||||
Specify "-text" to generate base64-encoded activation code.
|
Specify "--text" to generate base64-encoded activation code.
|
||||||
This parameter must be specified.
|
This parameter is mandatory.
|
||||||
|
|
||||||
[-adv] Enable advance mode.
|
[--adv] Enable advance mode.
|
||||||
This parameter is optional.
|
This parameter is optional.
|
||||||
|
|
||||||
<RSA-2048 Private Key File> A path to an RSA-2048 private key file.
|
<RSA-2048 private key file> A path to an RSA-2048 private key file.
|
||||||
This parameter must be specified.
|
This parameter is mandatory.
|
||||||
```
|
```
|
||||||
|
|
||||||
__Example:__
|
__Example:__
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ ./navicat-keygen -text ./RegPrivateKey.pem
|
$ ./navicat-keygen --text ./RegPrivateKey.pem
|
||||||
```
|
```
|
||||||
|
|
||||||
You will be asked to select Navicat language and give major version number. After that an randomly generated __snKey__ will be given.
|
You will be asked to select Navicat language and give major version number. After that an randomly generated __snKey__ will be given.
|
||||||
|
|
|
||||||
|
|
@ -108,23 +108,23 @@
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage:
|
Usage:
|
||||||
navicat-keygen <-bin|-text> [-adv] <RSA-2048 Private Key File>
|
navicat-keygen <--bin|-text> [--adv] <RSA-2048 private key file>
|
||||||
|
|
||||||
<-bin|-text> Specify "-bin" to generate "license_file" used by Navicat 11.
|
<--bin|--text> Specify "--bin" to generate "license_file" used by Navicat 11.
|
||||||
Specify "-text" to generate base64-encoded activation code.
|
Specify "--text" to generate base64-encoded activation code.
|
||||||
This parameter must be specified.
|
This parameter is mandatory.
|
||||||
|
|
||||||
[-adv] Enable advance mode.
|
[--adv] Enable advance mode.
|
||||||
This parameter is optional.
|
This parameter is optional.
|
||||||
|
|
||||||
<RSA-2048 Private Key File> A path to an RSA-2048 private key file.
|
<RSA-2048 private key file> A path to an RSA-2048 private key file.
|
||||||
This parameter must be specified.
|
This parameter is mandatory.
|
||||||
```
|
```
|
||||||
|
|
||||||
__例如:__
|
__例如:__
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ ./navicat-keygen -text ./RegPrivateKey.pem
|
$ ./navicat-keygen --text ./RegPrivateKey.pem
|
||||||
```
|
```
|
||||||
|
|
||||||
你会被要求选择Navicat产品类别、Navicat语言版本和填写主版本号。之后一个随机生成的 __序列号__ 将会给出。
|
你会被要求选择Navicat产品类别、Navicat语言版本和填写主版本号。之后一个随机生成的 __序列号__ 将会给出。
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "navicat_serial_generator.hpp"
|
#include "navicat_serial_generator.hpp"
|
||||||
#include "rsa_cipher.hpp"
|
#include "rsa_cipher.hpp"
|
||||||
|
|
||||||
#define NKG_CURRENT_SOURCE_FILE() u8".\\navicat-keygen\\wmain.cpp"
|
#define NKG_CURRENT_SOURCE_FILE() ".\\navicat-keygen\\wmain.cpp"
|
||||||
#define NKG_CURRENT_SOURCE_LINE() __LINE__
|
#define NKG_CURRENT_SOURCE_LINE() __LINE__
|
||||||
|
|
||||||
namespace nkg {
|
namespace nkg {
|
||||||
|
|
@ -32,20 +32,20 @@ void welcome() {
|
||||||
|
|
||||||
void help() {
|
void help() {
|
||||||
puts("Usage:");
|
puts("Usage:");
|
||||||
puts(" navicat-keygen.exe <-bin|-text> [-adv] <RSA-2048 Private Key File>");
|
puts(" navicat-keygen <--bin|-text> [--adv] <RSA-2048 private key file>");
|
||||||
puts("");
|
puts("");
|
||||||
puts(" <-bin|-text> Specify \"-bin\" to generate \"license_file\" used by Navicat 11.");
|
puts(" <--bin|--text> Specify \"--bin\" to generate \"license_file\" used by Navicat 11.");
|
||||||
puts(" Specify \"-text\" to generate base64-encoded activation code.");
|
puts(" Specify \"--text\" to generate base64-encoded activation code.");
|
||||||
puts(" This parameter must be specified.");
|
puts(" This parameter is mandatory.");
|
||||||
puts("");
|
puts("");
|
||||||
puts(" [-adv] Enable advance mode.");
|
puts(" [--adv] Enable advance mode.");
|
||||||
puts(" This parameter is optional.");
|
puts(" This parameter is optional.");
|
||||||
puts("");
|
puts("");
|
||||||
puts(" <RSA-2048 Private Key File> A path to an RSA-2048 private key file.");
|
puts(" <RSA-2048 private key file> A path to an RSA-2048 private key file.");
|
||||||
puts(" This parameter must be specified.");
|
puts(" This parameter is mandatory.");
|
||||||
puts("");
|
puts("");
|
||||||
puts("Example:");
|
puts("Example:");
|
||||||
puts(" navicat-keygen.exe -text .\\RegPrivateKey.pem");
|
puts(" navicat-keygen --text ./RegPrivateKey.pem");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
@ -55,33 +55,31 @@ int main(int argc, char* argv[]) {
|
||||||
nkg::fnCollectInformation lpfnCollectInformation;
|
nkg::fnCollectInformation lpfnCollectInformation;
|
||||||
nkg::fnGenerateLicense lpfnGenerateLicense;
|
nkg::fnGenerateLicense lpfnGenerateLicense;
|
||||||
|
|
||||||
if (strcmp(argv[1], "-bin") == 0) {
|
if (strcmp(argv[1], "--bin") == 0) {
|
||||||
lpfnGenerateLicense = nkg::GenerateLicenseBinary;
|
lpfnGenerateLicense = nkg::GenerateLicenseBinary;
|
||||||
} else if (strcmp(argv[1], "-text") == 0) {
|
} else if (strcmp(argv[1], "--text") == 0) {
|
||||||
lpfnGenerateLicense = nkg::GenerateLicenseText;
|
lpfnGenerateLicense = nkg::GenerateLicenseText;
|
||||||
} else {
|
} else {
|
||||||
help();
|
help();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 4) {
|
if (argc == 3) {
|
||||||
if (strcmp(argv[2], "-adv") == 0) {
|
lpfnCollectInformation = nkg::CollectInformationNormal;
|
||||||
|
} else if (argc == 4 && strcmp(argv[2], "--adv") == 0) {
|
||||||
lpfnCollectInformation = nkg::CollectInformationAdvanced;
|
lpfnCollectInformation = nkg::CollectInformationAdvanced;
|
||||||
} else {
|
} else {
|
||||||
help();
|
help();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
lpfnCollectInformation = nkg::CollectInformationNormal;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nkg::rsa_cipher cipher;
|
nkg::rsa_cipher cipher;
|
||||||
|
|
||||||
cipher.import_private_key_file(argv[argc - 1]);
|
cipher.import_private_key_file(argv[argc - 1]);
|
||||||
if (cipher.bits() != 2048) {
|
if (cipher.bits() != 2048) {
|
||||||
throw nkg::exception(NKG_CURRENT_SOURCE_FILE(), NKG_CURRENT_SOURCE_LINE(), u8"RSA key length mismatches.")
|
throw nkg::exception(NKG_CURRENT_SOURCE_FILE(), NKG_CURRENT_SOURCE_LINE(), "RSA key length != 2048 bits.")
|
||||||
.push_hint(u8"You must provide an RSA key whose modulus length is 2048 bits.");
|
.push_hint("You must provide an RSA key whose modulus length is 2048 bits.");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sn_generator = lpfnCollectInformation();
|
auto sn_generator = lpfnCollectInformation();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user