Minishlink\WebPush\Encryption::createContext PHP Method

createContext() private static method

See section 4.2 of {@link https://tools.ietf.org/html/draft-ietf-httpbis-encryption-encoding-00} From {@link https://github.com/GoogleChrome/push-encryption-node/blob/master/src/encrypt.js}.
private static createContext ( $clientPublicKey, $serverPublicKey ) : string
$clientPublicKey string The client's public key
$serverPublicKey string Our public key
return string
    private static function createContext($clientPublicKey, $serverPublicKey)
    {
        if (Utils::safeStrlen($clientPublicKey) !== 65) {
            throw new \ErrorException('Invalid client public key length');
        }
        // This one should never happen, because it's our code that generates the key
        if (Utils::safeStrlen($serverPublicKey) !== 65) {
            throw new \ErrorException('Invalid server public key length');
        }
        $len = chr(0) . 'A';
        // 65 as Uint16BE
        return chr(0) . $len . $clientPublicKey . $len . $serverPublicKey;
    }