diff --git a/sha.c b/sha.c index eff318b..bc6bfdb 100644 --- a/sha.c +++ b/sha.c @@ -753,7 +753,10 @@ void usage(void) int main(int argc, char *argv[]) { static uint8_t key[16] = "aixiao.me"; + int key_l = 0; char sh_file[1024]; + + int opt; char optstrs[] = ":k:f:h?"; while (-1 != (opt = getopt(argc, argv, optstrs))) { @@ -764,7 +767,6 @@ int main(int argc, char *argv[]) case 'f': strcpy((char *)sh_file, optarg); break; - case ':': //printf("\nMissing argument after: -%c\n", optopt); usage(); @@ -777,11 +779,16 @@ int main(int argc, char *argv[]) } } - if (strlen((char *)key) < 8) { - printf("Key must be at least 8 digits!\n"); + key_l = strlen((char *)key); + //printf("%d\n", key_l); + + + if (key_l < 8 || key_l > 15) { + printf("The key must be 8-15 digits!\n"); exit(1); } + open_file(sh_file); struct AES_ctx ctx;