1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

PGP: Format fingerprints

This commit is contained in:
James Booth 2015-08-30 02:12:05 +01:00
parent b4722632b6
commit 688be91c23
4 changed files with 34 additions and 1 deletions

View File

@ -4238,7 +4238,9 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
ProfPGPKey *key = g_hash_table_lookup(keys, curr->data); ProfPGPKey *key = g_hash_table_lookup(keys, curr->data);
cons_show(" %s", key->name); cons_show(" %s", key->name);
cons_show(" ID : %s", key->id); cons_show(" ID : %s", key->id);
cons_show(" Fingerprint : %s", key->fp); char *format_fp = p_gpg_format_fp_str(key->fp);
cons_show(" Fingerprint : %s", format_fp);
free(format_fp);
if (key->secret) { if (key->secret) {
cons_show(" Type : PUBLIC, PRIVATE"); cons_show(" Type : PUBLIC, PRIVATE");
} else { } else {

View File

@ -671,6 +671,29 @@ p_gpg_autocomplete_key_reset(void)
autocomplete_reset(key_ac); autocomplete_reset(key_ac);
} }
char *
p_gpg_format_fp_str(char *fp)
{
if (!fp) {
return NULL;
}
GString *format = g_string_new("");
int i;
int len = strlen(fp);
for (i = 0; i < len; i++) {
g_string_append_c(format, fp[i]);
if (((i+1) % 4 == 0) && (i+1 < len)) {
g_string_append_c(format, ' ');
}
}
char *result = format->str;
g_string_free(format, FALSE);
return result;
}
static char* static char*
_remove_header_footer(char *str, const char * const footer) _remove_header_footer(char *str, const char * const footer)
{ {

View File

@ -69,5 +69,7 @@ char* p_gpg_decrypt(const char * const cipher);
void p_gpg_free_decrypted(char *decrypted); void p_gpg_free_decrypted(char *decrypted);
char* p_gpg_autocomplete_key(const char * const search_str); char* p_gpg_autocomplete_key(const char * const search_str);
void p_gpg_autocomplete_key_reset(void); void p_gpg_autocomplete_key_reset(void);
char* p_gpg_format_fp_str(char *fp);
#endif #endif

View File

@ -61,3 +61,9 @@ char * p_gpg_autocomplete_key(const char * const search_str)
return NULL; return NULL;
} }
char *
p_gpg_format_fp_str(char *fp)
{
return NULL;
}