Skip to content

Commit 90148ec

Browse files
authored
Merge pull request #26 from Recras/master
Fix CRC32 for certain strings
2 parents 15cb729 + 6bb7ba8 commit 90148ec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/LetterAvatar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ private function break_name(string $name): array
242242
*/
243243
private function stringToColor(string $string): string
244244
{
245+
$crc = hash('crc32b', $string);
245246
// random color
246-
$rgb = substr(dechex(crc32($string)), 0, 6);
247+
$rgb = substr($crc, 0, 6);
247248
// make it darker
248249
$darker = 2;
249250
list($R16, $G16, $B16) = str_split($rgb, 2);

0 commit comments

Comments
 (0)