当前位置: 首页>>代码示例>>Python>>正文


Python _ctypes.sizeof方法代码示例

本文整理汇总了Python中_ctypes.sizeof方法的典型用法代码示例。如果您正苦于以下问题:Python _ctypes.sizeof方法的具体用法?Python _ctypes.sizeof怎么用?Python _ctypes.sizeof使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_ctypes的用法示例。


在下文中一共展示了_ctypes.sizeof方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: to_c_mech

# 需要导入模块: import _ctypes [as 别名]
# 或者: from _ctypes import sizeof [as 别名]
def to_c_mech(self):
        """
        Create the Param structure, then convert the data into byte arrays.

        :return: :class:`~pycryptoki.cryptoki.CK_MECHANISM`
        """
        super(ECDH1DeriveMechanism, self).to_c_mech()
        params = CK_ECDH1_DERIVE_PARAMS()
        params.kdf = self.params["kdf"]
        if self.params["sharedData"] is None:
            shared_data = None
            shared_data_len = 0
        else:
            shared_data, shared_data_len = to_byte_array(self.params["sharedData"])
        params.pSharedData = cast(shared_data, CK_BYTE_PTR)
        params.ulSharedDataLen = shared_data_len
        public_data, public_data_len = to_byte_array(self.params["publicData"])
        params.pPublicData = cast(public_data, CK_BYTE_PTR)
        params.ulPublicDataLen = public_data_len
        self.mech.pParameter = cast(pointer(params), c_void_p)
        self.mech.usParameterLen = CK_ULONG(sizeof(params))
        return self.mech 
开发者ID:ThalesGroup,项目名称:pycryptoki,代码行数:24,代码来源:dh.py

示例2: _check_size

# 需要导入模块: import _ctypes [as 别名]
# 或者: from _ctypes import sizeof [as 别名]
def _check_size(typ, typecode=None):
    # Check if sizeof(ctypes_type) against struct.calcsize.  This
    # should protect somewhat against a misconfigured libffi.
    from struct import calcsize
    if typecode is None:
        # Most _type_ codes are the same as used in struct
        typecode = typ._type_
    actual, required = sizeof(typ), calcsize(typecode)
    if actual != required:
        raise SystemError("sizeof(%s) wrong: %d instead of %d" % \
                          (typ, actual, required)) 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:__init__.py

示例3: to_c_mech

# 需要导入模块: import _ctypes [as 别名]
# 或者: from _ctypes import sizeof [as 别名]
def to_c_mech(self):
        """
        Create the Param structure, then convert the data into byte arrays.

        :return: :class:`~pycryptoki.cryptoki.CK_MECHANISM`

        """
        super(PRFKDFDeriveMechanism, self).to_c_mech()
        params = CK_PRF_KDF_PARAMS()
        params.prfType = self.params["prf_type"]
        if self.params["label"] is None:
            label = ""
            label_len = 0
        else:
            label, label_len = to_byte_array(self.params["label"])
        if self.params["context"] is None:
            context = ""
            context_len = 0
        else:
            context, context_len = to_byte_array(self.params["context"])
        if self.params["counter"] is None:
            counter = 1
        else:
            counter = self.params["counter"]
        ul_encoding_scheme = self.params["encoding_scheme"]

        params.pLabel = cast(label, CK_BYTE_PTR)
        params.ulLabelLen = label_len
        params.pContext = cast(context, CK_BYTE_PTR)
        params.ulContextLen = context_len
        params.ulCounter = counter
        params.ulEncodingScheme = ul_encoding_scheme
        self.mech.pParameter = cast(pointer(params), c_void_p)
        self.mech.usParameterLen = CK_ULONG(sizeof(params))
        return self.mech 
开发者ID:ThalesGroup,项目名称:pycryptoki,代码行数:37,代码来源:kdf.py

示例4: create_unicode_buffer

# 需要导入模块: import _ctypes [as 别名]
# 或者: from _ctypes import sizeof [as 别名]
def create_unicode_buffer(init, size=None):
    """create_unicode_buffer(aString) -> character array
    create_unicode_buffer(anInteger) -> character array
    create_unicode_buffer(aString, anInteger) -> character array
    """
    if isinstance(init, str):
        if size is None:
            if sizeof(c_wchar) == 2:
                # UTF-16 requires a surrogate pair (2 wchar_t) for non-BMP
                # characters (outside [U+0000; U+FFFF] range). +1 for trailing
                # NUL character.
                size = sum(2 if ord(c) > 0xFFFF else 1 for c in init) + 1
            else:
                # 32-bit wchar_t (1 wchar_t per Unicode character). +1 for
                # trailing NUL character.
                size = len(init) + 1
        buftype = c_wchar * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, int):
        buftype = c_wchar * init
        buf = buftype()
        return buf
    raise TypeError(init)


# XXX Deprecated 
开发者ID:guohuadeng,项目名称:odoo13-x64,代码行数:30,代码来源:__init__.py


注:本文中的_ctypes.sizeof方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。