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
python类BYTE的实例源码
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)()
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)()
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)()
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)()
def byte_buffer(length):
"""Get a buffer for a string"""
return (BYTE * length)()
list_ports_windows.py 文件源码
项目:get_started_with_respeaker
作者: respeaker
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
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)()
def byte_buffer(length):
"""Get a buffer for a string"""
return (BYTE*length)()