private static function validateKey($key, $size)
    {
        $length = strlen($key);

        if ($length < $size) {
            $key = str_pad($key, $size, $key);
        } elseif ($length > $size) {
            $key = substr($key, 0, $size);
        }

        return $key;
    }