__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace SpomkyLabs\Pki\X509\GeneralName;
use UnexpectedValueException;
use function array_slice;
use function count;
use function sprintf;
final class IPv6Address extends IPAddress
{
public static function create(string $ip, ?string $mask = null): self
{
return new self($ip, $mask);
}
/**
* Initialize from octets.
*/
public static function fromOctets(string $octets): self
{
$mask = null;
$words = unpack('n*', $octets);
$words = $words === false ? [] : $words;
switch (count($words)) {
case 8:
$ip = self::wordsToIPv6String($words);
break;
case 16:
$ip = self::wordsToIPv6String(array_slice($words, 0, 8));
$mask = self::wordsToIPv6String(array_slice($words, 8, 8));
break;
default:
throw new UnexpectedValueException('Invalid IPv6 octet length.');
}
return self::create($ip, $mask);
}
/**
* Convert an array of 16 bit words to an IPv6 string representation.
*
* @param int[] $words
*/
protected static function wordsToIPv6String(array $words): string
{
$groups = array_map(static fn ($word) => sprintf('%04x', $word), $words);
return implode(':', $groups);
}
protected function octets(): string
{
$words = array_map('hexdec', explode(':', $this->ip));
if (isset($this->mask)) {
$words = array_merge($words, array_map('hexdec', explode(':', $this->mask)));
}
return pack('n*', ...$words);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| DNSName.php | File | 1.23 KB | 0664 |
|
| DirectoryName.php | File | 1.53 KB | 0664 |
|
| EDIPartyName.php | File | 1.17 KB | 0664 |
|
| GeneralName.php | File | 3.27 KB | 0664 |
|
| GeneralNames.php | File | 4.47 KB | 0664 |
|
| IPAddress.php | File | 2.1 KB | 0664 |
|
| IPv4Address.php | File | 1.26 KB | 0664 |
|
| IPv6Address.php | File | 1.63 KB | 0664 |
|
| OtherName.php | File | 1.9 KB | 0664 |
|
| RFC822Name.php | File | 1.15 KB | 0664 |
|
| RegisteredID.php | File | 1.32 KB | 0664 |
|
| UniformResourceIdentifier.php | File | 1.16 KB | 0664 |
|
| X400Address.php | File | 1.13 KB | 0664 |
|