:type version: int
        :type messageKeys: MessageKeys
        :type  plainText: bytearray
964050
def getCiphertext(self, version, messageKeys, plainText):
        
        cipher = None
        if version >= 3:
            cipher = self.getCipher(messageKeys.getCipherKey(), messageKeys.getIv())
        else:
            cipher = self.getCipher_v2(messageKeys.getCipherKey(), messageKeys.getCounter())

        return cipher.encrypt(bytes(plainText))
511587
def [](key)
      if key.instance_of?(0.class)
        @slave.send("read_#{@type}", key, 1)
      elsif key.instance_of?(Range)
        @slave.send("read_#{@type}s", key.first, key.count)
      else
        raise ModBus::Errors::ProxyException, "Invalid argument, must be integer or range. Was #{key.class}"
      end
    end
403484
private byte[] readBytes(final int numBytes, String messageType) throws IOException {
    final String errMsg = isNullOrEmpty(messageType)
                          ? "Error reading from ssh-agent."
                          : "Error reading " + messageType + " from ssh-agent.";

    final byte[] result = new byte[numBytes];

    final int bytesRead;
    try {
      bytesRead = in.read(result, 0, numBytes);
    } catch (IOException e) {
      log.error(errMsg);
      throw Throwables.propagate(e);
    }

    if (bytesRead == -1) {
      log.error(errMsg);
      throw new IOException(errMsg);
    }

    return result;
  }
1111575
public static byte[] encryptAsBytes(final String plainText) throws Exception {
        final SecretKey secretKey = KeyManager.getInstance().getSecretKey();
        return encryptAsBytes(secretKey, plainText);
    }
183804
def change_version_byte(address, new_version=None, new_crypto=None):
    
    if not new_version and new_crypto:
        try:
            new_version = crypto_data[new_crypto]['address_version_byte']
        except KeyError:
            raise CurrencyNotSupported("Unknown currency symbol: " + new_crypto)

        if not new_version:
            raise CurrencyNotSupported("Can't yet make %s addresses." % new_crypto)

    payload = b58decode_check(address)[1:]
    if is_py2:
        byte = chr(new_version)
    else:
        byte = bytes(chr(new_version), 'ascii')

    return b58encode_check(byte + payload)
235515
public MessageVersion getMessageVersion(String version)
    {
        MessageVersion recMessageVersion = this.getMessageVersion();
        recMessageVersion.setKeyArea(MessageVersion.CODE_KEY);
        version = MessageControl.fixVersion(version);
        recMessageVersion.getField(MessageVersion.CODE).setString(version);
        try {
            if (version != null)
                if (recMessageVersion.seek(DBConstants.EQUALS))
            {
                return recMessageVersion;
            }
        } catch (DBException e) {
            e.printStackTrace();
        }
        return (MessageVersion)((ReferenceField)this.getField(MessageControl.DEFAULT_VERSION_ID)).getReference();
    }
1052249
def version_msg():
    """"""
    python_version = sys.version[:3]
    location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    message = u'Cookiecutter %(version)s from {} (Python {})'
    return message.format(location, python_version)
817859
def version(self):
        
        request_params = dict(self.request_params)
        request_url = str(self.request_url)

        result = self.do_http_request(
            'get',
            request_url,
            data=request_params,
            custom_header=str(self.etiquette)
        ).json()

        return result['message-version']
209623
def idcode(msg):
    

    if df(msg) not in [5, 21]:
        raise RuntimeError("Message must be Downlink Format 5 or 21.")

    mbin = hex2bin(msg)

    C1 = mbin[19]
    A1 = mbin[20]
    C2 = mbin[21]
    A2 = mbin[22]
    C4 = mbin[23]
    A4 = mbin[24]
    # _ = mbin[25]
    B1 = mbin[26]
    D1 = mbin[27]
    B2 = mbin[28]
    D2 = mbin[29]
    B4 = mbin[30]
    D4 = mbin[31]

    byte1 = int(A4+A2+A1, 2)
    byte2 = int(B4+B2+B1, 2)
    byte3 = int(C4+C2+C1, 2)
    byte4 = int(D4+D2+D1, 2)

    return str(byte1) + str(byte2) + str(byte3) + str(byte4)
986619
def nlmsg_type(self, value):
        """"""
        self.bytearray[self._get_slicers(1)] = bytearray(c_uint16(value or 0))
861647
def multiply_encrypted_to_plaintext(public, encrypted, plaintext, output):
    
    log("Loading public key")
    publickeydata = json.load(public)
    pub = load_public_key(publickeydata)

    log("Loading encrypted number")
    enc = load_encrypted_number(encrypted, pub)

    log("Loading unencrypted number")
    num = float(plaintext)

    log("Multiplying")
    enc_result = enc * num

    serialised_result = serialise_encrypted(enc_result)
    print(serialised_result, file=output)
1288800
def to_payload
      version.htb << [depth].pack('C') << parent_fingerprint.htb <<
          [number].pack('N') << chain_code << [0x00].pack('C') << key.priv_key.htb
    end
1269514
def encrypt(self, paddedMessage):
        
        # TODO: make this less ugly and python 2 and 3 compatible
        # paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMessage) is unicode else paddedMessage)
        if (sys.version_info >= (3, 0) and
                not type(paddedMessage) in (bytes, bytearray)) or type(paddedMessage) is unicode:
            paddedMessage = bytearray(paddedMessage.encode())
        else:
            paddedMessage = bytearray(paddedMessage)

        sessionRecord = self.sessionStore.loadSession(self.recipientId, self.deviceId)
        sessionState = sessionRecord.getSessionState()
        chainKey = sessionState.getSenderChainKey()
        messageKeys = chainKey.getMessageKeys()
        senderEphemeral = sessionState.getSenderRatchetKey()
        previousCounter = sessionState.getPreviousCounter()
        sessionVersion = sessionState.getSessionVersion()

        ciphertextBody = self.getCiphertext(sessionVersion, messageKeys, paddedMessage)
        ciphertextMessage = WhisperMessage(sessionVersion, messageKeys.getMacKey(),
                                           senderEphemeral, chainKey.getIndex(),
                                           previousCounter, ciphertextBody,
                                           sessionState.getLocalIdentityKey(),
                                           sessionState.getRemoteIdentityKey())

        if sessionState.hasUnacknowledgedPreKeyMessage():
            items = sessionState.getUnacknowledgedPreKeyMessageItems()
            localRegistrationid = sessionState.getLocalRegistrationId()

            ciphertextMessage = PreKeyWhisperMessage(sessionVersion, localRegistrationid, items.getPreKeyId(),
                                                     items.getSignedPreKeyId(), items.getBaseKey(),
                                                     sessionState.getLocalIdentityKey(),
                                                     ciphertextMessage)
        sessionState.setSenderChainKey(chainKey.getNextChainKey())
        self.sessionStore.storeSession(self.recipientId, self.deviceId, sessionRecord)

        return ciphertextMessage
693
def register_builtin_message_types():
    """"""
    from .plain import PlainTextMessage
    from .email import EmailTextMessage, EmailHtmlMessage
    register_message_types(PlainTextMessage, EmailTextMessage, EmailHtmlMessage)
1086071
def byte2int(s, index=0):
    
    if six.PY2:
        return ord(s[index])
    return s[index]
817523
def get_version(self):
        

        result = self._client.get("version").content

        if isinstance(result, bytes):
            result = result.decode('utf-8')

        return result.strip('\n')
794030
def decrypt(self, senderKeyMessageBytes):
        
        try:
            record = self.senderKeyStore.loadSenderKey(self.senderKeyName)
            if record.isEmpty():
                raise NoSessionException("No sender key for: %s" % self.senderKeyName)
            senderKeyMessage = SenderKeyMessage(serialized = bytes(senderKeyMessageBytes))
            senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId())

            senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic())

            senderKey = self.getSenderKey(senderKeyState, senderKeyMessage.getIteration())

            plaintext = self.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText())

            self.senderKeyStore.storeSenderKey(self.senderKeyName, record)

            return plaintext
        except (InvalidKeyException, InvalidKeyIdException) as e:
            raise InvalidMessageException(e)