| Updated: October 28, 2024 | 
Obfuscate file and directory names by replacing some characters
#include <sys/slog2.h>
int slog2_obfuscate( slog2_obf_t obf_type,
                     char obf_char,
                     uint32_t flags,
                     const char *input,
                     size_t size,
                     char *output );
The slog2_obfuscate() function creates an obfuscated version of a string by replacing portions of it with a given character.
The obfuscated output string length is truncated to size - 1 characters if the output buffer is smaller than the size required to store input.
When obf_char isn't the null character, the resulting obfuscated output string always produces the same output for a given string. When obf_char is the null character, the obfuscated output string value will be identical within a similar timeframe across all processes.
For file and directory names:
For example (using . as the replacement character):
| Before | After | 
|---|---|
| dir/file.txt | d.r/f..e.txt | 
| my_fav_dir/my_file.txt | my......ir/my...le.txt | 
Because this function depends on the random number generator, make sure that /dev/random is running before you start slogger2.
0 on success, or -1 if an error occurred.
| Safety: | |
|---|---|
| Cancellation point | No | 
| Interrupt handler | Yes | 
| Signal handler | Yes | 
| Thread | Yes |