File indexing completed on 2026-04-17 07:59:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <cstdint>
0021 #include <string>
0022
0023 #include "arrow/util/span.h"
0024 #include "arrow/util/visibility.h"
0025
0026 namespace arrow::util {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class ARROW_EXPORT SecureString {
0038 public:
0039 SecureString() = default;
0040 SecureString(SecureString&&) noexcept;
0041 SecureString(const SecureString&) = default;
0042 explicit SecureString(std::string&&) noexcept;
0043 explicit SecureString(size_t, char) noexcept;
0044
0045 SecureString& operator=(SecureString&&) noexcept;
0046 SecureString& operator=(const SecureString&);
0047 SecureString& operator=(std::string&&) noexcept;
0048
0049 bool operator==(const SecureString&) const;
0050 bool operator!=(const SecureString&) const;
0051
0052 ~SecureString() { Dispose(); }
0053
0054 [[nodiscard]] bool empty() const;
0055 [[nodiscard]] std::size_t size() const;
0056 [[nodiscard]] std::size_t length() const;
0057 [[nodiscard]] std::size_t capacity() const;
0058
0059 [[nodiscard]] span<uint8_t> as_span();
0060 [[nodiscard]] span<const uint8_t> as_span() const;
0061 [[nodiscard]] std::string_view as_view() const;
0062
0063 void Dispose();
0064
0065 static void SecureClear(std::string*);
0066 static void SecureClear(uint8_t* data, size_t size);
0067
0068 private:
0069 std::string secret_;
0070 };
0071
0072 }