本文整理匯總了Python中ecdsa.util.sigencode_der方法的典型用法代碼示例。如果您正苦於以下問題:Python util.sigencode_der方法的具體用法?Python util.sigencode_der怎麽用?Python util.sigencode_der使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ecdsa.util
的用法示例。
在下文中一共展示了util.sigencode_der方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sign
# 需要導入模塊: from ecdsa import util [as 別名]
# 或者: from ecdsa.util import sigencode_der [as 別名]
def sign(self, data, deterministic=True):
return sigencode_der(*self.raw_sign(data, deterministic))
示例2: sign
# 需要導入模塊: from ecdsa import util [as 別名]
# 或者: from ecdsa.util import sigencode_der [as 別名]
def sign(message, pem):
message = message.encode()
sk = SigningKey.from_pem(pem)
signed = sk.sign(message, hashfunc=hashlib.sha256,
sigencode=ecdsaUtil.sigencode_der)
return binascii.hexlify(signed).decode()
示例3: sign
# 需要導入模塊: from ecdsa import util [as 別名]
# 或者: from ecdsa.util import sigencode_der [as 別名]
def sign(message, pem):
message = message.encode()
sk = SigningKey.from_pem(pem)
signed = sk.sign(message, hashfunc=hashlib.sha256, sigencode=ecdsaUtil.sigencode_der)
return binascii.hexlify(signed).decode()
示例4: _add_ecdsa_signature
# 需要導入模塊: from ecdsa import util [as 別名]
# 或者: from ecdsa.util import sigencode_der [as 別名]
def _add_ecdsa_signature(self, request_kwargs):
method = request_kwargs.get('method', 'GET')
if method in ('GET', 'DELETE'):
request_kwargs.setdefault('params', {})
request_kwargs['params']['__nonce'] = int(time.time())
data = urlencode(request_kwargs['params'])
else:
request_kwargs.setdefault('json', {})
request_kwargs['json']['__nonce'] = int(time.time())
data = json.dumps(request_kwargs['json'])
contract = '\n'.join(
(method, request_kwargs['path'], data)).encode('utf-8')
signature_bytes = self.private_key.sign(
contract, sigencode=sigencode_der, hashfunc=sha256)
signature = b2a_hex(signature_bytes).decode('ascii')
request_kwargs['headers'].update(
{
'x-signature': signature,
'x-pubkey': ecdsa_to_hex(self.public_key.to_string()),
})