Switch outbound data cipher.
550522
def set_outbound_cipher(
        self,
        block_engine,
        block_size,
        mac_engine,
        mac_size,
        mac_key,
        sdctr=False,
    ):
        
        self.__block_engine_out = block_engine
        self.__sdctr_out = sdctr
        self.__block_size_out = block_size
        self.__mac_engine_out = mac_engine
        self.__mac_size_out = mac_size
        self.__mac_key_out = mac_key
        self.__sent_bytes = 0
        self.__sent_packets = 0
        # wait until the reset happens in both directions before clearing
        # rekey flag
        self.__init_count |= 1
        if self.__init_count == 3:
            self.__init_count = 0
            self.__need_rekey = False
1185580
def encrypt(data, digest=True):
    """"""
    alg = get_best_algorithm()
    enc = implementations["encryption"][alg](
        data, implementations["get_key"]()
    )
    return "%s$%s" % (alg, (_to_hex_digest(enc) if digest else enc))
1286205
def switch(self, idx, u):
        """"""
        self.u[self.uid[idx]] = u
        self.rebuild = True
        self.system.dae.factorize = True
        logger.debug('<Line> Status switch to {} on idx {}.'.format(u, idx))
178597
private function switchMode()
    {
        switch ( $this->getModeName() )
        {
            case self::NUMERIC_MODE:
                return new NumericMode;

            case self::ALPHA_NUMERIC_MODE:
                return new AlphanumericMode;

            case self::EIGHT_BITS_MODE:
            default:
                return new EightBitMode;
        }
    }
327683
def startDtmf():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x35)  # 00110101
    c = KeypadFacilityHdr(ieiKF=0x2C, eightBitKF=0x0)
    packet = a / b / c
    return packet
431579
def dict_to_switch(d):
    """"""
    def lookup(query):
        return d[query]
    lookup._always_inline_ = True
    unrolling_items = unrolling_iterable(d.items())
    return lookup
124172
def changebase(string, frm, to, minlen=0):
    
    if frm == to:
        return lpad(string, get_code_string(frm)[0], minlen)

    return encode(decode(string, frm), to, minlen)
829021
def transposition_cipher(key, message):
    
    ciphertext = [''] * key
    ml = len(message)
    for col in range(key):
        pointer = col
        while pointer < ml:
            ciphertext[col] += message[pointer]
            pointer += key

    return ''.join(ciphertext)
1272140
def aes_encrypt(mode, aes_key, aes_iv, *data):
    """"""
    encryptor = Cipher(
        algorithms.AES(aes_key),
        mode(aes_iv),
        backend=default_backend()).encryptor()

    result = None
    for value in data:
        result = encryptor.update(value)
    encryptor.finalize()

    return result, None if not hasattr(encryptor, 'tag') else encryptor.tag
964818
def p_switch_statement(self, p):
        """"""
        cases = []
        default = None
        # iterate over return values from case_block
        for item in p[5]:
            if isinstance(item, ast.Default):
                default = item
            elif isinstance(item, list):
                cases.extend(item)

        p[0] = ast.Switch(expr=p[3], cases=cases, default=default)
53600
def encrypt(self, msg):
        """"""
        iv = self.random_bytes(AES.block_size)
        ctr = Counter.new(AES.block_size * 8, initial_value=self.bin2long(iv))
        cipher = AES.AESCipher(self._cipherkey, AES.MODE_CTR, counter=ctr)
        cipher_text = cipher.encrypt(msg)
        intermediate = iv + cipher_text
        signature = self.sign(intermediate)
        return signature + intermediate
684887
private byte[] encryptInternal(SecretKeySpec key, String toEncrypt) {
        try {
            Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
            cipher.init(Cipher.ENCRYPT_MODE, key);
            return cipher.doFinal(toEncrypt.getBytes(ENCODING));
        } catch (GeneralSecurityException e) {
            throw new RuntimeException("Exception during decryptInternal: " + e, e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Exception during encryptInternal: " + e, e);
        }
    }
873867
def switch(self, value=None):
        """"""
        if self._hub is None or not self._fiber.is_alive():
            return
        self._hub.run_callback(self._fiber.switch, value)
        self._hub = self._fiber = None
112014
def update_reserved_switch_binding(switch_ip, state):
    """"""

    # overload port_id to contain switch state
    update_reserved_binding(
        const.NO_VLAN_OR_VNI_ID,
        switch_ip,
        const.RESERVED_NEXUS_SWITCH_DEVICE_ID_R1,
        state)
1342578
private byte[] cipher(byte[] input, int mode)
    {
        try
        {
            return doCipher(input, mode);
        }
        catch (Exception e)
        {
            throw new IllegalStateException(e);
        }
    }
301788
def swap(self):
        """"""
        self.xmin, self.ymin = self.ymin, self.xmin
        self.xmax, self.ymax = self.ymax, self.xmax
904655
private void switchToBackward() {
        assert((checkDir > 0 && seq == rawSeq) || (checkDir == 0 && pos == start));
        if(checkDir > 0) {
            // Turn around from forward checking.
            limit = segmentLimit = pos;
            if(pos == segmentStart) {
                start = rawStart;
                checkDir = -1;  // Check backward.
            } else {  // pos > segmentStart
                checkDir = 0;  // Stay in FCD segment.
            }
        } else {
            // Reached the start of the FCD segment.
            if(seq == rawSeq) {
                // The input text segment is FCD, extend it backward.
            } else {
                // The input text segment needed to be normalized.
                // Switch to checking backward from it.
                seq = rawSeq;
                pos = limit = segmentLimit = segmentStart;
            }
            start = rawStart;
            checkDir = -1;
        }
    }