Encrypt data with a curve25519 version of the ed25519 public key

        :param data: Bytes data to encrypt
774480
def encrypt_seal(self, data: Union[str, bytes]) -> bytes:
        
        curve25519_public_key = libnacl.crypto_sign_ed25519_pk_to_curve25519(self.pk)
        return libnacl.crypto_box_seal(ensure_bytes(data), curve25519_public_key)
597350
public function encrypt($data)
    {
        return openssl_encrypt($data, $this->algorithm, $this->secret, 0, $this->iv);
    }
183950
function (data, scheme) {
      scheme = scheme || SCHEME;
      return this._key.decrypt(forge.util.decode64(data), scheme);
    }
167971
def create(curve, data):
    
    ec_key = libcrypto.EC_KEY_new_by_curve_name(curve.nid)
    if ec_key is None:
        raise PKeyError("EC_KEY_new_by_curvename")
    group = libcrypto.EC_KEY_get0_group(ec_key)
    if group is None:
        raise PKeyError("EC_KEY_get0_group")
    libcrypto.EC_GROUP_set_asn1_flag(group, 1)
    raw_key = libcrypto.BN_new()
    if isinstance(data, int):
        libcrypto.BN_hex2bn(byref(raw_key), hex(data))
    else:
        if raw_key is None:
            raise PKeyError("BN_new")
        if libcrypto.BN_bin2bn(data, len(data), raw_key) is None:
            raise PKeyError("BN_bin2bn")
    ctx = libcrypto.BN_CTX_new()
    if ctx is None:
        raise PKeyError("BN_CTX_new")
    order = libcrypto.BN_new()
    if order is None:
        raise PKeyError("BN_new")
    priv_key = libcrypto.BN_new()
    if priv_key is None:
        raise PKeyError("BN_new")
    if libcrypto.EC_GROUP_get_order(group, order, ctx) <= 0:
        raise PKeyError("EC_GROUP_get_order")
    if libcrypto.BN_nnmod(priv_key, raw_key, order, ctx) <= 0:
        raise PKeyError("BN_nnmod")
    if libcrypto.EC_KEY_set_private_key(ec_key, priv_key) <= 0:
        raise PKeyError("EC_KEY_set_private_key")
    pub_key = libcrypto.EC_POINT_new(group)
    if pub_key is None:
        raise PKeyError("EC_POINT_new")
    if libcrypto.EC_POINT_mul(group, pub_key, priv_key, None, None, ctx) <= 0:
        raise PKeyError("EC_POINT_mul")
    if libcrypto.EC_KEY_set_public_key(ec_key, pub_key) <= 0:
        raise PKeyError("EC_KEY_set_public_key")
    libcrypto.BN_free(raw_key)
    libcrypto.BN_free(order)
    libcrypto.BN_free(priv_key)
    libcrypto.BN_CTX_free(ctx)
    pkey = libcrypto.EVP_PKEY_new()
    if pkey is None:
        raise PKeyError("EVP_PKEY_new")
    if libcrypto.EVP_PKEY_set1_EC_KEY(pkey, ec_key) <= 0:
        raise PKeyError("EVP_PKEY_set1_EC_KEY")
    libcrypto.EC_KEY_free(ec_key)
    return PKey(ptr=pkey, cansign=True)
163250
public function encrypt($data)
    {
        try {
            return openssl_encrypt($data, self::$algorithm, self::$pass);
        } catch (\Exception $e) {
            return $data;
        }
    }
95255
def decrypt(self, data):
        
        next_payload, is_critical, payload_len = const.PAYLOAD_HEADER.unpack(data[:const.PAYLOAD_HEADER.size])
        next_payload = payloads.Type(next_payload)
        logger.debug("next payload: {!r}".format(next_payload))
        try:
            iv_len = 16
            iv = bytes(data[const.PAYLOAD_HEADER.size:const.PAYLOAD_HEADER.size + iv_len])
            ciphertext = bytes(data[const.PAYLOAD_HEADER.size + iv_len:payload_len])  # HMAC size
        except IndexError:
            raise IkeError('Unable to decrypt: Malformed packet')
        logger.debug('IV: {}'.format(dump(iv)))
        logger.debug('CIPHERTEXT: {}'.format(dump(ciphertext)))
        # Decrypt
        cipher = Camellia(self.SK_er, iv=iv)
        decrypted = cipher.decrypt(ciphertext)
        logger.debug("Decrypted packet from responder: {}".format(dump(decrypted)))
        return next_payload, decrypted
429823
public byte[] decrypt(String data, KeyType keyType) {
		return decrypt(SecureUtil.decode(data), keyType);
	}
632261
def to_curve25519_public_key(self):
        
        raw_pk = nacl.bindings.crypto_sign_ed25519_pk_to_curve25519(self._key)
        return _Curve25519_PublicKey(raw_pk)
530424
def Encrypt(self, data):
    """"""
    encryptor = self.GetEncryptor()
    padded_data = self.Pad(data)

    try:
      return encryptor.update(padded_data) + encryptor.finalize()
    except ValueError as e:
      raise CipherError(e)
135433
def CryptUnprotectData(
	data, optional_entropy=None, prompt_struct=None, flags=0):
	
	data_in = DATA_BLOB(data)
	entropy = DATA_BLOB(optional_entropy) if optional_entropy else None
	data_out = DATA_BLOB()
	ptr_description = wintypes.LPWSTR()
	res = _CryptUnprotectData(
		data_in,
		ctypes.byref(ptr_description),
		entropy,
		None,  # reserved
		prompt_struct,
		flags | CRYPTPROTECT_UI_FORBIDDEN,
		data_out,
	)
	handle_nonzero_success(res)
	description = ptr_description.value
	if ptr_description.value is not None:
		ctypes.windll.kernel32.LocalFree(ptr_description)
	res = data_out.get_data()
	data_out.free()
	return description, res
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;
	}
915007
public byte[] encryptData(PublicKey key,byte[] data)
    {
    	try {
    		if(data==null || data.length<=0)
    		{
    			return null;
    		}
			Cipher cipher=Cipher.getInstance(algorithm);
			cipher.init(Cipher.ENCRYPT_MODE, key);
			return cipher.doFinal(data);
		} catch (Exception e) {
			log.error(e.getMessage(),e);
		}
    	return null;
    }
849889
function encryptPQInnerDataWithRSA(context) {
    // Create the data with hash to be encrypt
    var hash = utility.createSHAHash(context.pqInnerData);
    var dataWithHash = Buffer.concat([hash, context.pqInnerData]);
    if (logger.isDebugEnabled()) {
        logger.debug('Data to be encrypted contains: hash(%s), pqInnerData(%s), total length %s',
            hash.length, context.pqInnerData.length, dataWithHash.length);
    }
    // Encrypt data with RSA
    context.encryptedData = security.cipher.rsaEncrypt(dataWithHash, context.publicKey);
    return context;
}
786731
public byte[] encryptData(byte[] data) throws SymmetricKeyException {
        Encryptor encryptor = createEncryptor();
        byte[] encrypted = encryptor.encrypt(data);
        byte[] trailer = encryptor.encrypt(null);
        if (encrypted == null || trailer == null)
            throw new SymmetricKeyException("Cannot encrypt data");
        byte[] result = ArrayUtils.concat(encrypted, trailer);
        return result;
    }
100639
def public_key_from_ed25519_key(hex_public_key):
    """"""
    public_key = crypto.Ed25519VerifyingKey(bytes.fromhex(hex_public_key), encoding='bytes')
    return public_key.encode(encoding='base58').decode('utf-8')
787310
def verify(self, signature, data):
        
        return self._pk.public_key.verify(signature, data)
1283318
public function encrypt($data) {
        if (is_array($data)) return array_map([$this, __FUNCTION__], $data);
        openssl_private_encrypt($data, $result, $this->key);
        return base64_encode($result);
    }