Return the bytes for a key signature event.
961241
def key_signature_event(self, key='C'):
        """"""
        if key.islower():
            val = minor_keys.index(key) - 7
            mode = '\x01'
        else:
            val = major_keys.index(key) - 7
            mode = '\x00'
        if val < 0:
            val = 256 + val
        key = a2b_hex('%02x' % val)
        return '{0}{1}{2}\x02{3}{4}'.format(self.delta_time, META_EVENT,
                KEY_SIGNATURE, key, mode)
1248920
def key_bytes(self):
        
        return self.key.private_bytes(
            encoding=serialization.Encoding.DER,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption(),
        )
97279
def bytes(self):
        """"""
        byteout = bytearray()
        for i in range(1, 15):
            key = 'd' + str(i)
            if self._userdata[key] is not None:
                byteout.append(self._userdata[key])
            else:
                byteout.append(0x00)
        return byteout
579624
def read_key(pysam_alignment_record):
    '''
    
    '''
    return (
        pysam_alignment_record.query_name,
        pysam_alignment_record.is_duplicate,
        pysam_alignment_record.is_read1,
        pysam_alignment_record.is_read2,
    )
1193387
def get_bytes(s):
    """"""
    if isinstance(s, bytes):
        b = s
    elif isinstance(s, str):
        b = bytes.fromhex(s)
    else:
        raise TypeError("s must be either 'bytes' or 'str'!")

    return b
650795
def _compute_key(self, id, nbytes):
        ""
        m = Message()
        m.add_mpint(self.K)
        m.add_bytes(self.H)
        m.add_byte(id)
        m.add_bytes(self.session_id)
        out = sofar = SHA.new(str(m)).digest()
        while len(out) < nbytes:
            m = Message()
            m.add_mpint(self.K)
            m.add_bytes(self.H)
            m.add_bytes(sofar)
            digest = SHA.new(str(m)).digest()
            out += digest
            sofar += digest
        return out[:nbytes]
531431
def request_signature(self, stringtosign):
        
        digest = hmac.new(
            self.secret_key.encode(ENCODING),
            stringtosign.encode(ENCODING),
            hashlib.sha1
        ).digest()
        return b64_string(digest)
590308
def _get_storage_key(self, identified_with, identifier):
        """"""
        return ':'.join((
            self.key_prefix, identified_with.name,
            self.hash_identifier(identified_with, identifier),
        ))
1107900
public static byte[] signMessage(RSAPrivateKey key, byte[] message)
            throws InvalidKeyException, NoSuchAlgorithmException, SignatureException {
        return signMessage(key, message, DEFAULT_SIGNATURE_ALGORITHM);
    }
1125115
def _get_key_value(self, event, event_type):
        """"""
        if event_type == 10:
            value = 1
        elif event_type == 11:
            value = 0
        elif event_type == 12:
            value = self._get_flag_value(event)
        else:
            value = -1
        return value
194932
function( signature, input, key ) {

    var check = this.sign( input, key )

    return signature.toString( 'hex' ) ===
      check.toString( 'hex' )

  }
931792
def _jks_keystream(iv, password):
    """"""
    cur = iv
    while 1:
        xhash = hashlib.sha1(bytes(password + cur)) # hashlib.sha1 in python 2.6 does not accept a bytearray argument
        cur = bytearray(xhash.digest()) # make sure we iterate over ints in both Py2 and Py3
        for byte in cur:
            yield byte
261480
def _get(self, key):
        
        buf = BytesIO()

        self._get_file(key, buf)

        return buf.getvalue()
272546
def get_witness_for_key_prefix(db, node_hash, key):
    
    validate_is_bytes(key)

    return tuple(_get_witness_for_key_prefix(db, node_hash, encode_to_bin(key)))
1070019
def get_boulder_header(key_bytes):
    
    pub_hex, pub_exp = re.search(
        r"modulus:\n\s+00:([a-f0-9\:\s]+?)\npublicExponent: ([0-9]+)",
        key_bytes.decode('utf8'), re.MULTILINE | re.DOTALL).groups()
    pub_exp = "{0:x}".format(int(pub_exp))
    pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
    header = {
        "alg": "RS256",
        "jwk": {
            "e": _b64(binascii.unhexlify(pub_exp.encode("utf-8"))),
            "kty": "RSA",
            "n": _b64(binascii.unhexlify(re.sub(r"(\s|:)", "", pub_hex).encode("utf-8"))),
        },
    }

    return header
676974
def key_size(self):
        
        if self.key_algorithm in {PubKeyAlgorithm.ECDSA, PubKeyAlgorithm.ECDH}:
            return self._key.keymaterial.oid
        return next(iter(self._key.keymaterial)).bit_length()
584555
public byte getKeyAsByte(int index) throws IOException {
        if (index >= structure.keySizes.size()) {
            throw new IOException("Index " + index + " is out of range.");
        }
        return key[structure.keyByteOffsets.get(index)];
    }