Dcrypt\Rc4::initializeState PHP Method

initializeState() protected static method

Create the initial byte matrix that will be used for swaps. This code is identical between RC4 and Spritz.
protected static initializeState ( string $key ) : array
$key string
return array
    protected static function initializeState($key)
    {
        $s = \range(0, 255);
        $j = 0;
        foreach (\range(0, 255) as $i) {
            $j = ($j + $s[$i] + \ord($key[$i % Str::strlen($key)])) % 256;
            $x = $s[$i];
            $s[$i] = $s[$j];
            $s[$j] = $x;
        }
        return $s;
    }