aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/GpgConstants.cpp
diff options
context:
space:
mode:
authorSaturn&Eric <[email protected]>2021-12-07 08:37:54 +0000
committerGitHub <[email protected]>2021-12-07 08:37:54 +0000
commitcc89ad54ab3dd4aeb3ed7afeed59a80b6e61649c (patch)
tree865d2298d836c8eb36584b5d268325bca4a66a78 /src/gpg/GpgConstants.cpp
parentMerge pull request #26 from saturneric/develop (diff)
parentFix Bugs on KeyUploadDialog (diff)
downloadGpgFrontend-cc89ad54ab3dd4aeb3ed7afeed59a80b6e61649c.tar.gz
GpgFrontend-cc89ad54ab3dd4aeb3ed7afeed59a80b6e61649c.zip
Merge pull request #28 from saturneric/develop
Diffstat (limited to 'src/gpg/GpgConstants.cpp')
-rw-r--r--src/gpg/GpgConstants.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gpg/GpgConstants.cpp b/src/gpg/GpgConstants.cpp
index 5688287e..e3de1d06 100644
--- a/src/gpg/GpgConstants.cpp
+++ b/src/gpg/GpgConstants.cpp
@@ -77,12 +77,15 @@ gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err,
std::string GpgFrontend::beautify_fingerprint(
GpgFrontend::BypeArrayConstRef fingerprint) {
- auto _fingerprint = fingerprint;
- unsigned len = fingerprint.size();
- if ((len > 0) && (len % 4 == 0))
- for (unsigned n = 0; 4 * (n + 1) < len; ++n)
- _fingerprint.insert(static_cast<int>(5u * n + 4u), " ");
- return fingerprint;
+ auto len = fingerprint.size();
+ std::stringstream out;
+ decltype(len) count = 0;
+ while (count < len) {
+ if (count && !(count % 5)) out << " ";
+ out << fingerprint[count];
+ count++;
+ }
+ return out.str();
}
// trim from start (in place)