Sets key of account.

@param string $publicKey Public key
@param string $confirm Signature of empty string generated using secret key
501159
public function setAccountKey(string $publicKey, string $confirm)
    {
        $this->publicKey = $publicKey;
        $this->confirm = $confirm;
    }
1355963
public function setConfirmCode($code)
    {
        if (!$this->confirmCodeAttribute || empty($this->confirmCodeAttribute)) {
            return;
        }
        $confirmCodeAttribute = $this->confirmCodeAttribute;
        $this->$confirmCodeAttribute = $code;
        if (!$this->confirmTimeAttribute) {
            return;
        }
        $confirmTimeAttribute = $this->confirmTimeAttribute;
        if (!empty($code)) {
            $this->$confirmTimeAttribute = date('Y-m-d H:i:s');
            return;
        }
        $this->$confirmTimeAttribute = $this->initConfirmTime;
    }
1213631
public function sign($contents, $privateKey)
    {
        $rsa = new RSA();
        $rsa->loadKey($privateKey);

        $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);

        return $rsa->sign($contents);
    }
1207380
public function setUserAccountConfirmationStatus($username, $confirmed = true)
    {
        $this->username = $username;
        $this->getMeta()->confirmed = $confirmed;
        $this->getMeta()->save();
    }
1036367
public boolean setPublicKey (String key)
    {
        return key == null ? false : setPublicKey(SecureUtil.stringToRSAPublicKey(key));
    }
507706
private function prepare_signing_key() {
    $this->signing_key = $this->safe_encode($this->config['consumer_secret']) . '&' . $this->safe_encode($this->config['user_secret']);
  }
883142
public boolean setPublicKey (PublicKey key)
    {
        if (SecureUtil.ciphersSupported(key)) {
            _publicKey = key;
            return true;
        }
        return false;
    }
815528
public function encryptByPublicKey_data($data, $publickey = '')
	{
		$RSACrypt = new RSACrypt();

		if ($publickey != "") {
			$RSACrypt->pubkey = $publickey;
		}
		$crypt_res = "";
		for ($i = 0; $i < ((strlen($data) - strlen($data) % 117) / 117 + 1); $i++) {
			$crypt_res = $crypt_res . ($RSACrypt->encryptByPublicKey(mb_strcut($data, $i * 117, 117, 'utf-8')));
		}
		return $crypt_res;
	}
260767
public function calculateSharedSecret(PublicKey $publicKey) : SharedSecret
    {
        $exchange = $this->getEccKey()->createExchange($publicKey->getEccKey());
        $binary = new BinaryString(gmp_export($exchange->calculateSharedKey()));

        return new SharedSecret($binary);
    }
764517
function publicKeyVerify(key) {
  if (key.length === 0)
    return false;

  switch (key[0]) {
    case 0x02:
    case 0x03:
      return key.length === 33;
    case 0x04:
      if (key.length !== 65)
        return false;

      return secp256k1.publicKeyVerify(key);
    default:
      return false;
  }
}
78138
public function create($name, $publicKey)
    {
        $key = $this->adapter->post(sprintf('%s/account/keys', $this->endpoint), ['name' => $name, 'public_key' => $publicKey]);

        $key = json_decode($key);

        return new KeyEntity($key->ssh_key);
    }
1178971
public static function retrieve($publickey = null, $secretkey = null)
    {
        return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
    }
224072
public function isValid($key)
    {
        if (! isset ($this['sso'], $this['sig'])) {
            return false;
        }

        return $this['sig'] === Secret::create($key)->sign($this['sso']);
    }
589818
public function setKey($key)
    {
        $this->key = $this->chiper->encrypt($key);
        parent::setKey($this->key);
    }
721002
public function setCredentials($appId, $secretKey)
    {
        $this->appId = $appId;
        $this->secretKey = $secretKey;
        return $this;
    }
498107
public function getTokenForPublicKey($publicKey)
    {
        if (!$this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $publicKey)) {
            return false;
        }
        
        // Get the access entity
        $accessEntity = $this->accessControlManager->getAccessEntityForName(self::ACCESS_ENTITY_TYPE, $publicKey);

        if ($accessEntity === false) {
            return false;
        }
        
        return $accessEntity;
    }
991964
public static function decryptRsaPublic(string $data, string $publicKey, string $format = null): string
    {
        $data = self::toRaw($data, $format);
        $key = \openssl_pkey_get_public($publicKey);

        $decrypted = '';
        if (!\openssl_public_decrypt($data, $decrypted, $key, OPENSSL_PKCS1_OAEP_PADDING)) {
            throw new CryptoException('RSA public decrypt error: ' . openssl_error_string());
        }
        \openssl_pkey_free($key);

        return $decrypted;
    }