Ability to generate pass phrases as well as names.
This commit is contained in:
parent
0156f8c3c8
commit
4c12f368f5
@ -44,8 +44,9 @@ void usage() {
|
|||||||
" m, med, medium | Copy-friendly, 8 characters, contains symbols.\n"
|
" m, med, medium | Copy-friendly, 8 characters, contains symbols.\n"
|
||||||
" b, basic | 8 characters, no symbols.\n"
|
" b, basic | 8 characters, no symbols.\n"
|
||||||
" s, short | Copy-friendly, 4 characters, no symbols.\n"
|
" s, short | Copy-friendly, 4 characters, no symbols.\n"
|
||||||
" p, pin | 4 numbers.\n"
|
" i, pin | 4 numbers.\n"
|
||||||
" n, name | 9 letter name.\n\n", MP_env_sitetype);
|
" n, name | 9 letter name.\n"
|
||||||
|
" p, phrase | 20 character sentence.\n\n", MP_env_sitetype);
|
||||||
fprintf(stderr, " -c counter The value of the counter.\n"
|
fprintf(stderr, " -c counter The value of the counter.\n"
|
||||||
" Defaults to %s in env or '1'.\n\n", MP_env_sitecounter);
|
" Defaults to %s in env or '1'.\n\n", MP_env_sitecounter);
|
||||||
fprintf(stderr, " -v variant The kind of content to generate.\n"
|
fprintf(stderr, " -v variant The kind of content to generate.\n"
|
||||||
|
@ -31,10 +31,12 @@ const MPElementType TypeWithName(const char *typeName) {
|
|||||||
return MPElementTypeGeneratedBasic;
|
return MPElementTypeGeneratedBasic;
|
||||||
if (0 == strcmp(lowerTypeName, "s") || 0 == strcmp(lowerTypeName, "short"))
|
if (0 == strcmp(lowerTypeName, "s") || 0 == strcmp(lowerTypeName, "short"))
|
||||||
return MPElementTypeGeneratedShort;
|
return MPElementTypeGeneratedShort;
|
||||||
if (0 == strcmp(lowerTypeName, "p") || 0 == strcmp(lowerTypeName, "pin"))
|
if (0 == strcmp(lowerTypeName, "i") || 0 == strcmp(lowerTypeName, "pin"))
|
||||||
return MPElementTypeGeneratedPIN;
|
return MPElementTypeGeneratedPIN;
|
||||||
if (0 == strcmp(lowerTypeName, "n") || 0 == strcmp(lowerTypeName, "name"))
|
if (0 == strcmp(lowerTypeName, "n") || 0 == strcmp(lowerTypeName, "name"))
|
||||||
return MPElementTypeGeneratedName;
|
return MPElementTypeGeneratedName;
|
||||||
|
if (0 == strcmp(lowerTypeName, "p") || 0 == strcmp(lowerTypeName, "phrase"))
|
||||||
|
return MPElementTypeGeneratedPhrase;
|
||||||
|
|
||||||
fprintf(stderr, "Not a generated type name: %s", lowerTypeName);
|
fprintf(stderr, "Not a generated type name: %s", lowerTypeName);
|
||||||
abort();
|
abort();
|
||||||
@ -72,6 +74,10 @@ const char *CipherForType(MPElementType type, uint8_t seedByte) {
|
|||||||
case MPElementTypeGeneratedName: {
|
case MPElementTypeGeneratedName: {
|
||||||
return "cvccvcvcv";
|
return "cvccvcvcv";
|
||||||
}
|
}
|
||||||
|
case MPElementTypeGeneratedPhrase: {
|
||||||
|
char *ciphers[] = { "cvcc cvc cvccvcv cvc", "cvc cvccvcvcv cvcv", "cv cvccv cvc cvcvccv" };
|
||||||
|
return ciphers[seedByte % 3];
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
fprintf(stderr, "Unknown generated type: %d", type);
|
fprintf(stderr, "Unknown generated type: %d", type);
|
||||||
abort();
|
abort();
|
||||||
@ -148,6 +154,10 @@ const char CharacterFromClass(char characterClass, uint8_t seedByte) {
|
|||||||
classCharacters = "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()";
|
classCharacters = "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ' ': {
|
||||||
|
classCharacters = " ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
fprintf(stderr, "Unknown character class: %c", characterClass);
|
fprintf(stderr, "Unknown character class: %c", characterClass);
|
||||||
abort();
|
abort();
|
||||||
|
@ -34,7 +34,8 @@ typedef enum {
|
|||||||
MPElementTypeGeneratedBasic = 0x4 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedBasic = 0x4 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedShort = 0x3 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedShort = 0x3 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedPIN = 0x5 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedPIN = 0x5 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedName = 0xF | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedName = 0xE | MPElementTypeClassGenerated | 0x0,
|
||||||
|
MPElementTypeGeneratedPhrase = 0xF | MPElementTypeClassGenerated | 0x0,
|
||||||
|
|
||||||
MPElementTypeStoredPersonal = 0x0 | MPElementTypeClassStored | MPElementFeatureExportContent,
|
MPElementTypeStoredPersonal = 0x0 | MPElementTypeClassStored | MPElementFeatureExportContent,
|
||||||
MPElementTypeStoredDevicePrivate = 0x1 | MPElementTypeClassStored | MPElementFeatureDevicePrivate,
|
MPElementTypeStoredDevicePrivate = 0x1 | MPElementTypeClassStored | MPElementFeatureDevicePrivate,
|
||||||
|
Loading…
Reference in New Issue
Block a user