Return the shard for this message
@param message
@return
321480
String getShardKey(Message message) {
        return getShardKey(message.getTokenTime(), this.modShardPolicy.getMessageShard(message, metadata));
    }
830829
public Shard getShard(String docId) {
        assertNotEmpty(docId, "docId");
        return client.couchDbClient.get(new DatabaseURIHelper(db.getDBUri()).path("_shards")
                        .path(docId).build(),
                Shard.class);
    }
281424
private long getIndexVersion(List<ShardIndexVersion> shards) {
    long version = 1;

    // order shards per their id before computing the hash
    Collections.sort(shards, new Comparator<ShardIndexVersion>() {
      @Override
      public int compare(ShardIndexVersion o1, ShardIndexVersion o2) {
        return o1.getShardRouting().id() - o2.getShardRouting().id();
      }
    });

    // compute hash
    for (ShardIndexVersion shard : shards) {
      version = 31 * version + shard.getVersion();
    }

    return version;
  }
1234378
public java.util.List<Shard> getShards() {
        if (shards == null) {
            shards = new com.amazonaws.internal.SdkInternalList<Shard>();
        }
        return shards;
    }
1284960
private byte[] getSha256(byte[] data) throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        return digest.digest(data);
    }
356765
private static byte[] sha1(byte[] data) {
		MessageDigest md = null;
		try {
			md = MessageDigest.getInstance(ALGORITHM_SHA1);
			md.reset();
			md.update(data);
			return md.digest();
		} catch (Exception e) {
			LogUtil.writeErrorLog("SHA1计算失败", e);
			return null;
		}
	}
207863
protected String getPayload(Message message) {
        try {
            String encoding = (String) message.get(Message.ENCODING);
            if (encoding == null) {
                encoding = "UTF-8";
            }
            CachedOutputStream cos = message.getContent(CachedOutputStream.class);
            if (cos == null) {
                LOG.warning("Could not find CachedOutputStream in message."
                        + " Continuing without message content");
                return "";
            }
            return new String(cos.getBytes(), encoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
434114
public static String sha512(final String data) {
        return digest(MessageDigestAlgorithms.SHA_512, data.getBytes(StandardCharsets.UTF_8));
    }
339522
def get_shard_map(self, force_refresh=False):
        
        now = datetime.utcnow()
        if force_refresh is True or \
                        self.shard_map is None or \
                        (now - self.last_refresh).total_seconds() > self.refresh_ttl:
            self.last_refresh = now
            self.refresh_shard_map()
        return self.shard_map
872147
public String createMessageData(String message) {

		messageStringBuffer.delete(0, messageStringBuffer.length());

		// Create the PRI part
		messageStringBuffer.append('<');
		int priority = facility * 8 + severity;
		messageStringBuffer.append(priority);
		messageStringBuffer.append('>');

		// Create the HEADER part.
		if (header) {
			// Add the TIMESTAMP field of the HEADER
			// Time format is "Mmm dd hh:mm:ss". For more info see rfc3164.
			long currentTime = System.currentTimeMillis();
			calendar.setTime(new Date(currentTime));

			messageStringBuffer.append(SyslogMessage.MONTHS[calendar
					.get(Calendar.MONTH)]);
			messageStringBuffer.append(' ');

			int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
			if (dayOfMonth < SyslogMessage.TEN) {
				messageStringBuffer.append('0');
			}
			messageStringBuffer.append(dayOfMonth);
			messageStringBuffer.append(' ');

			int hour = calendar.get(Calendar.HOUR_OF_DAY);
			if (hour < SyslogMessage.TEN) {
				messageStringBuffer.append('0');
			}
			messageStringBuffer.append(hour);
			messageStringBuffer.append(':');

			int minute = calendar.get(Calendar.MINUTE);
			if (minute < SyslogMessage.TEN) {
				messageStringBuffer.append('0');
			}
			messageStringBuffer.append(minute);
			messageStringBuffer.append(':');

			int second = calendar.get(Calendar.SECOND);
			if (second < SyslogMessage.TEN) {
				messageStringBuffer.append('0');
			}
			messageStringBuffer.append(second);
			messageStringBuffer.append(' ');

			// Add the HOSTNAME part of the message
			messageStringBuffer.append(hostname);
		}

		// Create the MSG part.
		messageStringBuffer.append(' ');
		messageStringBuffer.append(tag);
		messageStringBuffer.append(": ");
		messageStringBuffer.append(message);

		return messageStringBuffer.toString();
	}
690476
def command(self, command, full_response=False, **kwargs): # pragma: no cover
        """"""
        command = Shard(c=command)
        return self.get_shards(*(command, Shard(**kwargs)), full_response=full_response)
692146
def hash_key(self):
        
        if self.conf.message_id:
            message_id = self.message.get('Message-Id')
            if message_id:
                return message_id.strip()
            logger.error(
                "No Message-ID in {}: {}".format(self.path, self.header_text))
            raise MissingMessageID

        return hashlib.sha224(self.canonical_headers).hexdigest()
1263077
public static byte[] sha256Bytes(String str) {
        if (str == null) return null;
        MessageDigest digester;
        try {
            digester = MessageDigest.getInstance("SHA-256");
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }
        return digester.digest(str.getBytes());
    }
137014
def get_shard_id2num_examples(num_shards, total_num_examples):
  """"""
  # TODO(b/130353071): This has the strong assumption that the shards have
  # been written in a round-robin fashion. This assumption does not hold, for
  # instance, with Beam generation. The mapping shard_id=>num_examples
  # should be computed during generation.

  # Minimum number of example per shards
  num_example_in_shard = total_num_examples // num_shards
  shard_id2num_examples = [num_example_in_shard for _ in range(num_shards)]
  # If there are remaining examples, we add them to the first shards
  for shard_id in range(total_num_examples % num_shards):
    shard_id2num_examples[shard_id] += 1
  return shard_id2num_examples
113369
def get_shard_by_num(self, shard_num):
        
        if shard_num < 0 or shard_num >= self.num_shards():
            raise ValueError("requested invalid shard# {0}".format(shard_num))

        return self._shards[shard_num]
677827
public byte[] getAnsiHash( byte[] challenge ) {
        if( hashesExternal ) {
            return ansiHash;
        }
        switch (LM_COMPATIBILITY) {
        case 0:
        case 1:
            return getPreNTLMResponse( password, challenge );
        case 2:
            return getNTLMResponse( password, challenge );
        case 3:
        case 4:
        case 5:
            if( clientChallenge == null ) {
                clientChallenge = new byte[8];
                RANDOM.nextBytes( clientChallenge );
            }
            return getLMv2Response(domain, username, password, challenge,
                    clientChallenge);
        default:
            return getPreNTLMResponse( password, challenge );
        }
    }
172854
def hashlib_sha256(message):
        
        hashlib_sha256 = hashlib.sha256()
        hashlib_sha256.update(message.encode('utf-8'))
        hashed_str = hashlib_sha256.hexdigest()
        return hashed_str