Encrypt or decrypt.
504578
private byte[] doCipher(byte[] input, int mode) throws
            DecoderException, InvalidKeyException, InvalidAlgorithmParameterException,
            IllegalBlockSizeException, BadPaddingException, EncoderException
    {
        if (input == null)
        {
            return null;
        }

        if (cipher == null)
        {
            throw new IllegalStateException("setCipher() has not been called.");
        }

        if (key == null && certificate == null)
        {
            throw new IllegalStateException("setInit() has not been called.");
        }

        if (mode == Cipher.DECRYPT_MODE)
        {
            input = decode(input);
        }

        initCipher(mode);

        byte[] output = cipher.doFinal(input);

        if (mode == Cipher.ENCRYPT_MODE)
        {
            output = encode(output);
        }

        return output;
    }
538255
def decrypt(self, encrypted):
        
        decoded = b64decode(encrypted)
        init_vec = decoded[:AES.block_size]
        cipher = AES.new(self._key, AES.MODE_CBC, init_vec)

        return AESCipher.unpad(cipher.decrypt(decoded[AES.block_size:]))
401925
def DecryptPassword(cipher, key):
		
		import base64
		import hmac
		import sha
		from array import array

		H = UcsUtils.GetShaHash

		cipher = cipher + "\n"
		cipher = base64.decodestring(cipher)
		n = len(cipher) - 16 - 8

		uhash = cipher[:16]
		passwordStream = cipher[16:-8] + "0000"[n & 3:]
		auth = cipher[-8:]

		k_enc, k_auth = H('enc' + key + uhash), H('auth' + key + uhash)
		vauth = hmac.new(cipher[-8:], k_auth, sha).digest()[:8]

		passwordStream = array('L', passwordStream)
		xkey = UcsUtils.Expandkey(k_enc, n + 4)

		for i in xrange(len(passwordStream)):
			passwordStream[i] = passwordStream[i] ^ xkey[i]

		decryptedPassword = passwordStream.tostring()[:n]
		return decryptedPassword
629416
def decrypt(self, data, decode=False):
		

		#result = self.cipher().decrypt(data)
		result = self.cipher().decrypt_block(data)

		padding = self.mode().padding()
		if padding is not None:
			result = padding.reverse_pad(result, WAESMode.__data_padding_length__)

		return result.decode() if decode else result
143656
function decrypt (input, firstKey = 0xAB) {
  const buf = Buffer.from(input);
  let key = firstKey;
  let nextKey;
  for (let i = 0; i < buf.length; i++) {
    nextKey = buf[i];
    buf[i] = buf[i] ^ key;
    key = nextKey;
  }
  return buf;
}
609900
def encrypt(message, modN, e, blockSize):
    """"""
    numList = string2numList(message)
    numBlocks = numList2blocks(numList, blockSize)  # only one block
    message = numBlocks[0]
    # return [modExp(blocks, e, modN) for blocks in numBlocks]
    return modExp(message, e, modN)
1107518
def encrypt(key, pt, Nk=4):
    """"""
    assert Nk in {4, 6, 8}
    rkey = key_expand(key, Nk)
    ct = cipher(rkey, pt, Nk)

    return ct
1034541
def decrypt(payload, private_key):
        """"""
        cipher = PKCS1_v1_5.new(private_key)
        aes_key_str = cipher.decrypt(b64decode(payload.get("aes_key")), sentinel=None)
        aes_key = json.loads(aes_key_str.decode("utf-8"))
        key = b64decode(aes_key.get("key"))
        iv = b64decode(aes_key.get("iv"))
        encrypted_magic_envelope = b64decode(payload.get("encrypted_magic_envelope"))
        encrypter = AES.new(key, AES.MODE_CBC, iv)
        content = encrypter.decrypt(encrypted_magic_envelope)
        return etree.fromstring(pkcs7_unpad(content))
637948
def Decrypt(self, encrypted_data):
    
    decrypted_data = self._rc4_cipher.decrypt(encrypted_data)
    return decrypted_data, b''
1161203
def enable_encryption(self, output_key, input_key):
        """"""
        self._chacha = chacha20.Chacha20Cipher(output_key, input_key)
203761
def decrypt_binary(self, binary, *args, **kwargs):
        
        return self.decrypt(binary, *args, **kwargs)
919319
def decrypt(self):
        
        if not self._crypter:
            return b''
        try:
            plaintext = self._crypter.decrypt(self._ciphertext, **self._decrypt_params)
            return plaintext
        except Exception as e:
            exc_info = sys.exc_info()
            six.reraise(
                ValueError('Invalid ciphertext "%s", error: %s' % (self._ciphertext, e)),
                None,
                exc_info[2]
            )
776910
def decrypt(encrypted)
      fail ArgumentError, 'No cipher text supplied.' if encrypted.nil? || encrypted.empty?

      matches = CIPHER_PATTERN.match(encrypted)

      fail ArgumentError, 'Cipher text has an unsupported format.' if matches.nil?

      cipher = self.class.cipher
      cipher.decrypt
      cipher.key = Base64.decode64(@key)
      cipher.iv = Base64.decode64(matches[1])
      decrypted = cipher.update(Base64.decode64(matches[2]))

      decrypted << cipher.final
    end
120988
private String decryptInternal(SecretKeySpec key, byte[] encryptedBytes) {
        try {
            Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
            return new String(decryptedBytes, ENCODING);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException("Exception during decryptInternal: " + e, e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Exception during encryptInternal: " + e, e);
        }
    }
228852
def encrypt(data, key, iv, cipher_type)
      aes = OpenSSL::Cipher.new(cipher_type)
      aes.encrypt
      aes.key = key
      aes.iv  = iv unless iv.nil?
      aes.update(data) + aes.final
    end
709687
def _cbc_encrypt(self, content, final_key):
        """"""

        aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv)
        padding = (16 - len(content) % AES.block_size)

        for _ in range(padding):
            content += chr(padding).encode()

        temp = bytes(content)
        return aes.encrypt(temp)
620039
def _disable_encryption(self):
        # () -> None
        """"""
        self.encrypt = self._disabled_encrypt
        self.decrypt = self._disabled_decrypt