3 ms·
Can you switch to ctypes? >>> from ctypes.util import find_library >>> find_library("c") '/usr/lib/libc.dylib' >>> from ctypes import cdll >>> libc =
by eesmith 3y ago
Can you switch to ctypes?
>>> from ctypes.util import find_library
>>> find_library("c")
'/usr/lib/libc.dylib'
>>> from ctypes import cdll
>>> libc = cdll.LoadLibrary(find_library("c"))
>>> import ctypes
>>> libc.crypt.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
>>> libc.crypt.restype = ctypes.c_char_p
>>> libc.crypt(b"toomanysecrets", b"az")
b'azi4LBG1VJohQ'
Here is what Python's own _crypt does:
>>> import _crypt
>>> _crypt.crypt("toomanysecrets", "az")
'azi4LBG1VJohQ'