dpapi.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码
def dpapi_decrypt_data(self, encrypted_bytes, entropy = extra_entropy):
    '''
    Decrypts data and returns byte string

    :param encrypted_bytes: The encrypted data
    :type encrypted_bytes: Bytes
    :param entropy: Extra entropy to add to the encryption process (optional)
    :type entropy: String or Bytes
    '''
    if not isinstance(encrypted_bytes, bytes) or not isinstance(entropy, bytes):
        self.fatal('The inputs to dpapi must be bytes')
    buffer_in      = c_buffer(encrypted_bytes, len(encrypted_bytes))
    buffer_entropy = c_buffer(entropy, len(entropy))
    blob_in        = DATA_BLOB(len(encrypted_bytes), buffer_in)
    blob_entropy   = DATA_BLOB(len(entropy), buffer_entropy)
    blob_out       = DATA_BLOB()
    if CryptUnprotectData(byref(blob_in), None, byref(blob_entropy), None,
        None, CRYPTPROTECT_UI_FORBIDDEN, byref(blob_out)):
        return get_data(blob_out)
    else:
        self.fatal('Failed to decrypt data')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号