mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 08:46:41 +01:00
enh(Foundation): add Poco::secureClear() for securely clearing a string by first overwriting it with zeroes.
This commit is contained in:
parent
bc29f30e5c
commit
3092ba5455
@ -763,6 +763,18 @@ struct CILess
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
void secureClear(T& str)
|
||||
/// Securely clears a string's contents by first overwriting
|
||||
/// the entire buffer (up to capacity) with zeroes, then
|
||||
/// clearing the string.
|
||||
{
|
||||
str.resize(str.capacity());
|
||||
std::fill(str.begin(), str.end(), typename T::value_type());
|
||||
str.clear();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
#if defined(__clang__) && ((__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ >= 6))
|
||||
|
Loading…
x
Reference in New Issue
Block a user