CLI: Clear displayed password after 30 seconds (if found)
This commit is contained in:
parent
09e0d85d97
commit
35f49d24b3
22
cli/main.c
22
cli/main.c
|
@ -40,6 +40,7 @@
|
|||
#define SERVER_PROTOCOL 4
|
||||
#define RESPONSE_SIZE 2048
|
||||
#define MAX_SUBDOMAINS 10
|
||||
#define DISPLAY_TIME 30 // 30 seconds
|
||||
|
||||
struct gpass_parameters {
|
||||
unsigned pbkdf2_level;
|
||||
|
@ -71,6 +72,25 @@ static const EVP_MD * s_md_256;
|
|||
|
||||
static EVP_CIPHER_CTX * s_cipher_ctx;
|
||||
|
||||
static void display_password(char* password, int time)
|
||||
{
|
||||
int length;
|
||||
|
||||
for (; time; time--)
|
||||
{
|
||||
printf("\r(%02d) Password found: %s", time, password);
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
// Clear line
|
||||
printf("\r");
|
||||
length = 4 + 17 + strlen(password) + 1;
|
||||
while (length--)
|
||||
printf(" ");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static int digest(unsigned char** out, unsigned char* in, unsigned size)
|
||||
{
|
||||
*out = NULL;
|
||||
|
@ -434,7 +454,7 @@ static int ask_server(struct gpass_parameters* params)
|
|||
memmove(password, &password[3], len-3);
|
||||
password[len-3] = 0;
|
||||
}
|
||||
printf("Password found: %s\n", password);
|
||||
display_password((char*)password, DISPLAY_TIME);
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user