我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用ctypes.wintypes.BYTE。
def encrypt(data, non_interactive=0): blobin = DATA_BLOB(cbData=len(data), pbData=cast(c_char_p(data), POINTER(wintypes.BYTE))) blobout = DATA_BLOB() if not CryptProtectData(byref(blobin), u('python-keyring-lib.win32crypto'), None, None, None, CRYPTPROTECT_UI_FORBIDDEN, byref(blobout)): raise OSError("Can't encrypt") encrypted = create_string_buffer(blobout.cbData) memmove(encrypted, blobout.pbData, blobout.cbData) windll.kernel32.LocalFree(blobout.pbData) return encrypted.raw
def decrypt(encrypted, non_interactive=0): blobin = DATA_BLOB(cbData=len(encrypted), pbData=cast(c_char_p(encrypted), POINTER(wintypes.BYTE))) blobout = DATA_BLOB() if not CryptUnprotectData(byref(blobin), u('python-keyring-lib.win32crypto'), None, None, None, CRYPTPROTECT_UI_FORBIDDEN, byref(blobout)): raise OSError("Can't decrypt") data = create_string_buffer(blobout.cbData) memmove(data, blobout.pbData, blobout.cbData) windll.kernel32.LocalFree(blobout.pbData) return data.raw
def byte_buffer(length): """Get a buffer for a string""" return (BYTE*length)()
def byte_buffer(length): """Get a buffer for a string""" return (BYTE * length)()