2021-11-01 02:52:29 +02:00
|
|
|
/*
|
|
|
|
barrier -- mouse and keyboard sharing utility
|
|
|
|
Copyright (C) Barrier contributors
|
|
|
|
|
|
|
|
This package is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
found in the file LICENSE that should have accompanied this file.
|
|
|
|
|
|
|
|
This package is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SecureUtils.h"
|
|
|
|
#include "base/String.h"
|
|
|
|
|
2021-11-01 02:52:35 +02:00
|
|
|
namespace barrier {
|
|
|
|
|
2021-11-01 02:52:37 +02:00
|
|
|
std::string format_ssl_fingerprint(const std::vector<uint8_t>& fingerprint, bool separator)
|
2021-11-01 02:52:29 +02:00
|
|
|
{
|
2021-11-01 02:52:37 +02:00
|
|
|
std::string result = barrier::string::to_hex(fingerprint, 2);
|
2021-11-01 02:52:29 +02:00
|
|
|
|
|
|
|
// all uppercase
|
2021-11-01 02:52:30 +02:00
|
|
|
barrier::string::uppercase(result);
|
2021-11-01 02:52:29 +02:00
|
|
|
|
|
|
|
if (separator) {
|
|
|
|
// add colon to separate each 2 characters
|
2021-11-01 02:52:30 +02:00
|
|
|
size_t separators = result.size() / 2;
|
2021-11-01 02:52:29 +02:00
|
|
|
for (size_t i = 1; i < separators; i++) {
|
2021-11-01 02:52:30 +02:00
|
|
|
result.insert(i * 3 - 1, ":");
|
2021-11-01 02:52:29 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-01 02:52:31 +02:00
|
|
|
return result;
|
2021-11-01 02:52:29 +02:00
|
|
|
}
|
2021-11-01 02:52:35 +02:00
|
|
|
|
|
|
|
} // namespace barrier
|