-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from SammyK/obfuscate-memcached-keys
Add key obfuscation to Memcached integration
- Loading branch information
Showing
4 changed files
with
105 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace DDTrace; | ||
|
||
final class Obfuscation | ||
{ | ||
const REPLACEMENT = '?'; | ||
const DEFAULT_GLUE = ' '; | ||
|
||
/** | ||
* Obfuscate secrets with a replacement | ||
* | ||
* @param string|array $keys | ||
* @param string $glue | ||
* @return string | ||
*/ | ||
public static function toObfuscatedString($keys, $glue = self::DEFAULT_GLUE) | ||
{ | ||
if (!is_array($keys)) { | ||
return self::REPLACEMENT; | ||
} | ||
$obfuscatedKeys = str_repeat(self::REPLACEMENT . $glue, count($keys)); | ||
return rtrim($obfuscatedKeys, $glue); | ||
} | ||
} |
Oops, something went wrong.