This commit is contained in:
Dennis Eichhorn 2020-04-19 01:25:29 +02:00
parent b1ded69873
commit 308261b2be
2 changed files with 4 additions and 4 deletions

View File

@ -241,12 +241,12 @@ final class MbStringUtils
*/
public static function mb_entropy(string $value) : float
{
$entropy = 0.0;
$entropy = 0.0;
$size = \mb_strlen($value);
$countChars = self::mb_count_chars($value);
foreach ($countChars as $v) {
$p = $v / $size;
$p = $v / $size;
$entropy -= $p * \log($p) / \log(2);
}

View File

@ -173,12 +173,12 @@ final class StringUtils
*/
public static function entropy(string $value) : float
{
$entropy = 0.0;
$entropy = 0.0;
$size = \strlen($value);
$countChars = \count_chars($value, 1);
foreach ($countChars as $v) {
$p = $v / $size;
$p = $v / $size;
$entropy -= $p * \log($p) / \log(2);
}