a method to retrieve byte data of appdata record

        :param record_key: string with name of record
        :param secret_key: [optional] string used to decrypt data
        :return: byte data for record body
761333
def load(self, record_key, secret_key=''):

        ''' 
            
        '''

        title = '%s.load' % self.__class__.__name__
    
    # validate inputs
        input_fields = {
            'record_key': record_key,
            'secret_key': secret_key
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)

    # construct path to file
        from os import path
        file_path = path.join(self.collection_folder, record_key)

    # validate existence of file
        if not path.exists(file_path):
            raise Exception('%s(record_key=%s) does not exist.' % (title, record_key))

    # open file and read data
        record_data = open(file_path, 'rb').read()
    
    # decrypt (if necessary)
        if secret_key:
            from labpack.encryption import cryptolab
            record_data = cryptolab.decrypt(record_data, secret_key)
    
        return record_data
656919
def _get_secrets(self, secure_data_path, version=None):
        
        if not version:
            version = "CURRENT"
        payload = {'versionId': str(version)}
        secret_resp = get_with_retry(str.join('', [self.cerberus_url, '/v1/secret/', secure_data_path]),
                                   params=payload, headers=self.HEADERS)

        throw_if_bad_response(secret_resp)

        return secret_resp.json()
1137042
def decrypt(self, data, oaep_hash_fn_name=None, mgf1_hash_fn_name=None):
		

		if self.__private_key is None:
			raise ValueError('Unable to call this method. Private key must be set')

		if oaep_hash_fn_name is None:
			oaep_hash_fn_name = self.__class__.__default_oaep_hash_function_name__

		if mgf1_hash_fn_name is None:
			mgf1_hash_fn_name = self.__class__.__default_mgf1_hash_function_name__

		oaep_hash_cls = getattr(hashes, oaep_hash_fn_name)
		mgf1_hash_cls = getattr(hashes, mgf1_hash_fn_name)

		return self.__private_key.decrypt(
			data,
			padding.OAEP(
				mgf=padding.MGF1(algorithm=mgf1_hash_cls()),
				algorithm=oaep_hash_cls(),
				label=None
			)
		)
695779
public static String decryptData(String base64Data, String key) throws Exception {
		Cipher cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING);
		cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(HashKit.md5(key).toLowerCase().getBytes(), ALGORITHM));
		return new String(cipher.doFinal(Base64Kit.decode(base64Data)));
	}
160464
def get_ecdh_key(self, other):
        '''
        
        '''
        if self.__secretkey is None:
            raise KeyTypeError('Wrong key type for operation')
        # Copy because curve25519_dh_CreateSharedKey changes secretkey
        tmp_secretkey = ffi.new(C_SECRETKEY, self.secretkey)
        ecdh_key = ffi.new(C_SHAREDKEY)
        lib.curve25519_dh_CreateSharedKey(
            ecdh_key, other.pubkey, tmp_secretkey)
        del tmp_secretkey
        return ffi.get_bytes(ecdh_key)
1058152
def get(key, profile=None):  # pylint: disable=W0613
    '''
    
    '''
    data = _get_values(profile)

    # Decrypt SDB data if specified in the profile
    if profile and profile.get('gpg', False):
        return salt.utils.data.traverse_dict_and_list(_decrypt(data), key, None)

    return salt.utils.data.traverse_dict_and_list(data, key, None)
326270
public static function getJsapiTicket($app_id, $app_secret) {
        $urlObj = array();
        $urlObj['appid'] = $app_id;
        $urlObj['secret'] = $app_secret;
        $urlObj['grant_type'] = 'client_credential';
        $queryStr = http_build_query($urlObj);
        $accessTokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?' . $queryStr;
        $resp = self::_getRequest($accessTokenUrl);
        $resp = json_decode($resp, true);
        if (!is_array($resp) || isset($resp['errcode'])) {
            return $resp;
        }

        $urlObj = array();
        $urlObj['access_token'] = $resp['access_token'];
        $urlObj['type'] = 'jsapi';
        $queryStr = http_build_query($urlObj);
        $jsapiTicketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?' . $queryStr;
        $resp = self::_getRequest($jsapiTicketUrl);

        return json_decode($resp, true);
    }
749656
def _get_encryption_key():
    ''''''
    # initialize ENCRYPTION_KEY the first time it is needed, so that
    # applications that use eulcore without using this specific
    # functionality do not get bogus warnings about SECRET_KEY size.
    global ENCRYPTION_KEY
    if ENCRYPTION_KEY is None:
        # NOTE: Blowfish key length is variable but must be 32-448 bits
        # (but PyCrypto does not actually make this information accessible)
        KEY_MIN_CHARS = 32/8
        KEY_MAX_CHARS = 448/8
        if KEY_MIN_CHARS <= len(settings.SECRET_KEY) <= KEY_MAX_CHARS:
            ENCRYPTION_KEY = settings.SECRET_KEY
        else:
            ENCRYPTION_KEY = hashlib.sha224(settings.SECRET_KEY).hexdigest()
            message = '''Django secret key (current length of %d) requires hashing for use as encryption key
            (to avoid hashing, should be %d-%d characters)''' % \
            (len(settings.SECRET_KEY), KEY_MIN_CHARS, KEY_MAX_CHARS)
            logger.warn(message)
    return ENCRYPTION_KEY
637948
def Decrypt(self, encrypted_data):
    
    decrypted_data = self._rc4_cipher.decrypt(encrypted_data)
    return decrypted_data, b''
1038116
def retrieve_blob(self, key, encoding=None):
        '''  '''
        blob_key = self.__retrieve(key)
        if blob_key is None:
            return None
        if not blob_key:
            raise Exception("Invalid blob_key")
        elif blob_key == JiCache.INTERNAL_BLOB:
            blob_data = self.__retrieve_internal_blob(key)
            return blob_data if not encoding else blob_data.decode(encoding)
        else:
            getLogger().debug("Key[{key}] -> [{blob_key}]".format(key=key, blob_key=blob_key))
            blob_file = os.path.join(self.blob_location, blob_key)
            return FileHelper.read(blob_file)
911148
public static byte[] decrypt(byte[] data, byte[] key) {
        checkNotNull(data);
        checkNotNull(key);
        checkArgument(key.length >= 5 && key.length <= 256);
        StreamCipher rc4 = new RC4Engine();
        rc4.init(false, new KeyParameter(key));
        byte[] decrypted = new byte[data.length];
        rc4.processBytes(data, 0, data.length, decrypted, 0);
        return decrypted;
    }
189483
def urlstate(self, encryption_key):
        
        lzma = LZMACompressor()
        urlstate_data = json.dumps(self._state_dict)
        urlstate_data = lzma.compress(urlstate_data.encode("UTF-8"))
        urlstate_data += lzma.flush()
        urlstate_data = _AESCipher(encryption_key).encrypt(urlstate_data)
        lzma = LZMACompressor()
        urlstate_data = lzma.compress(urlstate_data)
        urlstate_data += lzma.flush()
        urlstate_data = base64.urlsafe_b64encode(urlstate_data)
        return urlstate_data.decode("utf-8")
1289075
def encryption_key(self, alg, **kwargs):
        
        if not self.key:
            self.deserialize()

        try:
            tsize = ALG2KEYLEN[alg]
        except KeyError:
            raise UnsupportedAlgorithm(alg)

        if tsize <= 32:
            # SHA256
            _enc_key = sha256_digest(self.key)[:tsize]
        elif tsize <= 48:
            # SHA384
            _enc_key = sha384_digest(self.key)[:tsize]
        elif tsize <= 64:
            # SHA512
            _enc_key = sha512_digest(self.key)[:tsize]
        else:
            raise JWKException("No support for symmetric keys > 512 bits")

        logger.debug('Symmetric encryption key: {}'.format(
            as_unicode(b64e(_enc_key))))

        return _enc_key
152432
def _GetBytes(partition_key):
        
        if isinstance(partition_key, six.string_types):
            return bytearray(partition_key, encoding='utf-8')
        else:
            raise ValueError("Unsupported " + str(type(partition_key)) + " for partitionKey.")
446609
def getKey(self, key):
		
		data = self.getDictionary()
		if key in data:
			return data[key]
		else:
			return None
1340764
def _record_key(record: Record) -> List[Tuple[Column, str]]:
    ""
    return sorted(record.items())
1087529
def _get_key_data(d, key):
    
    d2 = ""
    try:
        d2 = d[key]
    except KeyError:
        logger_dataframes.info("get_key_data: KeyError: {}".format(key))
    return d2