HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/files.wb-cloud.nl/private_html/3rdparty/kornrunner/blurhash/src/Base83.php
<?php

namespace kornrunner\Blurhash;

use InvalidArgumentException;

class Base83 {
    private const ALPHABET = [
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
        'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
        'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
        'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',', '-', '.',
        ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~'
    ];

    private const BASE = 83;

    public static function encode(int $value, int $length): string {
        if (intdiv($value, self::BASE ** $length) != 0) {
            throw new InvalidArgumentException('Specified length is too short to encode given value.');
        }

        $result = '';
        for ($i = 1; $i <= $length; $i++) {
            $digit   = intdiv($value, self::BASE ** ($length - $i)) % self::BASE;
            $result .= self::ALPHABET[$digit];
        }
        return $result;
    }

    public static function decode(string $hash): int {
        $result = 0;
        foreach (str_split($hash) as $char) {
            $result = $result * self::BASE + (int) array_search($char, self::ALPHABET, true);
        }
        return $result;
    }
}