===== RS256, RS384, RS512 ==================================================
162485
function generateRsJws(protect, bits, key) {
  if (key instanceof Buffer) {
    key = key.toString();
  } else if (typeof key !== 'string') {
    throw new TypeError('Key must be a buffer or a UTF-8 string');
  }
  if (!key.includes('-----BEGIN') || !key.includes('KEY-----')) {
    throw new TypeError('Key must be a PEM formatted RSA private key');
  }
  let signer = crypto.createSign(`SHA${bits}`);
  let signature = buf2b64url(signer.update(protect).sign(key));
  return `${protect}.${signature}`;
}
482500
def systemInformationType5ter():
    """"""
    a = L2PseudoLength(l2pLength=0x12)
    b = TpPd(pd=0x6)
    c = MessageType(mesType=0x6)  # 00000110
    d = NeighbourCellsDescription2()
    packet = a / b / c / d
    return packet
105477
def __misphashtypes():
        
        hashtypes = ['md5', 'sha1', 'sha256', 'ssdeep', 'sha224', 'sha384', 'sha512', 'sha512/224', 'sha512/256',
                     'tlsh', 'authentihash']
        filenames = []
        for h in hashtypes:
            filenames.append('filename|{0}'.format(h))
        return hashtypes + filenames
795728
function parseChassisData(statusData) {
        // sample data : 20 00 60 71 or 20 00 60
        var numStr = statusData.replace(/\s/g, '');
        assert.ok(numStr.match(/^[0-9A-Fa-f]{8}$|^[0-9A-Fa-f]{6}$/),
                  "Invalid chassis status output : " + statusData);
        var uidCode = parseInt(numStr[4], 16);
        var powerCode = parseInt(numStr[1], 16);

        // UID status need last 2 bit , so use mask 0x3(0011)
        // Power status need last bit , so use mask 0x1(0001)
        return {
            uid: uidStatus[uidCode & 0x3],
            power: (powerCode & 0x1) === 1
        };
    }
1356616
function encode(rssi) {
  if(rssi < MIN_RSSI_DBM) {
    rssi = MIN_RSSI_DBM;
  }
  else if(rssi > MAX_RSSI_DBM) {
    rssi = MAX_RSSI_DBM;
  }
  else {
    rssi = Math.round(rssi);
  }

  return ('00' + (rssi - MIN_RSSI_DBM).toString(16)).substr(-2);
}
397570
def _parse_v2_advertisement(self, rssi, sender, data):
        

        if len(data) != 31:
            return

        # We have already verified that the device is an IOTile device
        # by checking its service data uuid in _process_scan_event so
        # here we just parse out the required information

        device_id, reboot_low, reboot_high_packed, flags, timestamp, \
        battery, counter_packed, broadcast_stream_packed, broadcast_value, \
        _mac = unpack("<LHBBLBBHLL", data[7:])

        reboots = (reboot_high_packed & 0xF) << 16 | reboot_low
        counter = counter_packed & ((1 << 5) - 1)
        broadcast_multiplex = counter_packed >> 5
        broadcast_toggle = broadcast_stream_packed >> 15
        broadcast_stream = broadcast_stream_packed & ((1 << 15) - 1)

        # Flags for version 2 are:
        #   bit 0: Has pending data to stream
        #   bit 1: Low voltage indication
        #   bit 2: User connected
        #   bit 3: Broadcast data is encrypted
        #   bit 4: Encryption key is device key
        #   bit 5: Encryption key is user key
        #   bit 6: broadcast data is time synchronized to avoid leaking
        #   information about when it changes

        self._device_scan_counts.setdefault(device_id, {'v1': 0, 'v2': 0})['v2'] += 1

        info = {'connection_string': sender,
                'uuid': device_id,
                'pending_data': bool(flags & (1 << 0)),
                'low_voltage': bool(flags & (1 << 1)),
                'user_connected': bool(flags & (1 << 2)),
                'signal_strength': rssi,
                'reboot_counter': reboots,
                'sequence': counter,
                'broadcast_toggle': broadcast_toggle,
                'timestamp': timestamp,
                'battery': battery / 32.0,
                'advertising_version':2}

        self._trigger_callback('on_scan', self.id, info, self.ExpirationTime)

        # If there is a valid reading on the advertising data, broadcast it
        if broadcast_stream != 0xFFFF & ((1 << 15) - 1):
            if self._throttle_broadcast and \
               self._check_update_seen_broadcast(sender, timestamp, broadcast_stream, broadcast_value,
                                                 broadcast_toggle, counter=counter, channel=broadcast_multiplex):
                return

            reading = IOTileReading(timestamp, broadcast_stream, broadcast_value, reading_time=datetime.datetime.utcnow())
            report = BroadcastReport.FromReadings(info['uuid'], [reading], timestamp)
            self._trigger_callback('on_report', None, report)
888467
private int ssMedian3(int Td, int PA, int v1, int v2, int v3) {
        if (T[start + Td + SA[PA + SA[v1]]] > T[start + Td + SA[PA + SA[v2]]]) {
            int t = v1;
            v1 = v2;
            v2 = t;
        }
        if (T[start + Td + SA[PA + SA[v2]]] > T[start + Td + SA[PA + SA[v3]]]) {
            if (T[start + Td + SA[PA + SA[v1]]] > T[start + Td + SA[PA + SA[v3]]]) {
                return v1;
            } else {
                return v3;
            }
        }
        return v2;
    }
880487
function buildRDSSubnetGroup(numZones = 0, { name = 'RDSSubnetGroup' } = {}) {
  if (numZones < 1) {
    return {};
  }

  const subnetIds = [];
  for (let i = 1; i <= numZones; i += 1) {
    subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` });
  }

  return {
    [name]: {
      Type: 'AWS::RDS::DBSubnetGroup',
      Properties: {
        DBSubnetGroupName: {
          Ref: 'AWS::StackName',
        },
        DBSubnetGroupDescription: {
          Ref: 'AWS::StackName',
        },
        SubnetIds: subnetIds,
      },
    },
  };
}
563068
def MSR(self, params):
        
        Rspecial, Rj = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params)

        self.check_arguments(LR_or_general_purpose_registers=(Rj,), special_registers=(Rspecial,))

        def MSR_func():
            # TODO add combination registers IEPSR, IAPSR, and EAPSR
            # http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/CHDBIBGJ.html
            # TODO update N Z C V flags
            if Rspecial in ('PSR', 'APSR'):
                # PSR ignores writes to IPSR and EPSR
                self.register['APSR'] = self.register[Rj]
            else:
                # Do nothing
                pass

        return MSR_func
1146969
@Override
	public List<WebcamDevice> getDevices() {
		synchronized (this) {
			List<String> stdout = CommanderUtil.execute(this.command);
			if (stdout.isEmpty() || stdout.get(0).toLowerCase().contains(MSG_COMMAND_NOT_FOUND)) {
				throw new UnsupportedOperationException(MSG_RASPI_NOT_INSTALLED);
			}

			stdout = CommanderUtil.execute(COMMAND_VCGENCMD);
			if (stdout.size() != 1) {
				return Collections.emptyList();
			}
			String cameraCheckOutput = stdout.get(0).trim();
			int supported = Integer.parseInt(
					cameraCheckOutput.substring(cameraCheckOutput.indexOf("=") + 1, cameraCheckOutput.indexOf(" ")));
			if (supported == 0) {
				if (LOGGER.isDebugEnabled()) {
					LOGGER.debug(MSG_HARDWARE_NOT_FOUND);
				}
				return Collections.emptyList();
			}
			int detected = Integer.parseInt(cameraCheckOutput.substring(cameraCheckOutput.lastIndexOf("=") + 1));
			List<WebcamDevice> devices = new ArrayList<>(detected);
			for (int i = 0; i < detected; i++) {
				WebcamDevice device = createIPCDevice(i, new LinkedHashMap<String, String>(arguments));
				devices.add(device);
			}
			deviceCalled = true;
			return devices;
		}
	}
883123
def devices(self):
        ''
        return self.fs is not None and [JFSDevice(d, self, parentpath=self.rootpath) for d in self.fs.devices.iterchildren()] or [x for x in []]
86040
def _py24_25_compat(self):
        
        if sys.version_info < (2, 6):
            # import_module() is used to avoid dep scanner.
            os_fork = import_module('mitogen.os_fork')
            mitogen.os_fork._notice_broker_or_pool(self)
745812
def format_idp_cert_multi(self):
        
        if 'x509certMulti' in self.__idp:
            if 'signing' in self.__idp['x509certMulti']:
                for idx in range(len(self.__idp['x509certMulti']['signing'])):
                    self.__idp['x509certMulti']['signing'][idx] = OneLogin_Saml2_Utils.format_cert(self.__idp['x509certMulti']['signing'][idx])

            if 'encryption' in self.__idp['x509certMulti']:
                for idx in range(len(self.__idp['x509certMulti']['encryption'])):
                    self.__idp['x509certMulti']['encryption'][idx] = OneLogin_Saml2_Utils.format_cert(self.__idp['x509certMulti']['encryption'][idx])
982478
function(properties) {
        this._handle = null;
        this._allowedServices = [];

        this.id = "unknown"; 
        this.name = null;
        this.adData = {
            appearance: null,
            txPower: null,
            rssi: null,
            manufacturerData: new Map(),
            serviceData: new Map()
        };
        this.gatt = new BluetoothRemoteGATTServer();
        this.gatt.device = this;
        this.uuids = [];

        mergeDictionary(this, properties);
    }
51150
def _hardware_count(self):
        
        return self._counts.get("hardware") + self._counts.get("serial") + self._counts.get("mbed")
101155
public static int cusparseXcsr2bsrNnz(
        cusparseHandle handle, 
        int dirA, 
        int m, 
        int n, 
        cusparseMatDescr descrA, 
        Pointer csrSortedRowPtrA, 
        Pointer csrSortedColIndA, 
        int blockDim, 
        cusparseMatDescr descrC, 
        Pointer bsrSortedRowPtrC, 
        Pointer nnzTotalDevHostPtr)
    {
        return checkResult(cusparseXcsr2bsrNnzNative(handle, dirA, m, n, descrA, csrSortedRowPtrA, csrSortedColIndA, blockDim, descrC, bsrSortedRowPtrC, nnzTotalDevHostPtr));
    }
69231
function pkcs1pad2(s, n) {
        if (n < s.length + 11) { // TODO: fix for utf-8
            console.error("Message too long for RSA");
            return null;
        }
        var ba = new Array();
        var i = s.length - 1;
        while (i >= 0 && n > 0) {
            var c = s.charCodeAt(i--);
            if (c < 128) { // encode using utf-8
                ba[--n] = c;
            }
            else if ((c > 127) && (c < 2048)) {
                ba[--n] = (c & 63) | 128;
                ba[--n] = (c >> 6) | 192;
            }
            else {
                ba[--n] = (c & 63) | 128;
                ba[--n] = ((c >> 6) & 63) | 128;
                ba[--n] = (c >> 12) | 224;
            }
        }
        ba[--n] = 0;
        var rng = new SecureRandom();
        var x = new Array();
        while (n > 2) { // random non-zero pad
            x[0] = 0;
            while (x[0] == 0) rng.nextBytes(x);
            ba[--n] = x[0];
        }
        ba[--n] = 2;
        ba[--n] = 0;
        return new BigInteger(ba);
    }