Skip to content

Commit

Permalink
Merge pull request #26 from Recras/master
Browse files Browse the repository at this point in the history
Fix CRC32 for certain strings
  • Loading branch information
yohangdev authored Nov 14, 2023
2 parents 15cb729 + 6bb7ba8 commit 90148ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/LetterAvatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ private function break_name(string $name): array
*/
private function stringToColor(string $string): string
{
$crc = hash('crc32b', $string);
// random color
$rgb = substr(dechex(crc32($string)), 0, 6);
$rgb = substr($crc, 0, 6);
// make it darker
$darker = 2;
list($R16, $G16, $B16) = str_split($rgb, 2);
Expand Down

0 comments on commit 90148ec

Please sign in to comment.