Skip to content

Commit 2a123dc

Browse files
committed
docs(readme-ru): add secret_string example
1 parent e888360 commit 2a123dc

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

README-RU.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ secure_buffer key(std::move(secret_string)); // обнуляет перемещ
141141
auto mac = hmac::get_hmac(key, payload, hmac::TypeHash::SHA256);
142142
```
143143
144+
Для дополнительной защиты в памяти можно использовать `hmac_cpp::secret_string`, который
145+
обфусцирует данные и по возможности закрепляет их в RAM:
146+
147+
```cpp
148+
#include <hmac_cpp/secret.hpp>
149+
150+
hmac_cpp::secret_string token("super-secret-token");
151+
152+
token.with_plaintext([](const uint8_t* p, size_t n){
153+
// p действует только внутри коллбэка
154+
});
155+
156+
token.clear();
157+
```
158+
144159
### HMAC (сырой буфер)
145160

146161
```cpp

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ secure_buffer key(std::move(secret_string)); // zeroizes moved-from string
142142
auto mac = hmac::get_hmac(key, payload, hmac::TypeHash::SHA256);
143143
```
144144
145+
For additional protection in memory, `hmac_cpp::secret_string` obfuscates
146+
the data and tries to keep it locked in RAM:
147+
148+
```cpp
149+
#include <hmac_cpp/secret.hpp>
150+
151+
hmac_cpp::secret_string token("super-secret-token");
152+
153+
token.with_plaintext([](const uint8_t* p, size_t n){
154+
// p is valid only inside the callback
155+
});
156+
157+
token.clear();
158+
```
159+
145160
### HMAC (raw buffer)
146161

147162
```cpp

0 commit comments

Comments
 (0)