From 15aba655f09729dfb82c6aa6083d81864d41b8fe Mon Sep 17 00:00:00 2001 From: aixiao Date: Mon, 30 Jan 2023 14:35:44 +0800 Subject: [PATCH] =?UTF-8?q?key=E5=8F=82=E6=95=B0=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E5=AF=BC=E8=87=B4bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sha.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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;