Find MD5 for a censored post's ID, return None if can't find.
336287
def find_censored_md5ext(post_id: int) -> Optional[str]:
    ""
    try:
        last_pull_date = LAST_PULL_DATE_FILE.read_text().strip()
    except FileNotFoundError:
        last_pull_date = ""

    date = datetime.utcnow()
    date = f"{date.year}{date.month}{date.day}"

    if last_pull_date != date:
        update_batches()
        LAST_PULL_DATE_FILE.parent.mkdir(exist_ok=True, parents=True)
        LAST_PULL_DATE_FILE.write_text(date)

    # Faster than converting every ID in files to int
    post_id = str(post_id)

    for batch in BATCHES_DIR.iterdir():
        with open(batch, "r") as content:
            for line in content:
                an_id, its_md5_ext = line.split(":")

                if post_id == an_id:
                    return its_md5_ext.rstrip().split(".")

    return None
1534
def md5(source):
    
    # fix passing char '+' from source
    source = source.replace("%2B", "+")
    with open(source) as file_to_check:
        data = file_to_check.read()
        return hashlib.md5(data).hexdigest()
280013
def md5_8_name(self, url):
        
        m = hashlib.md5()
        m.update(url.encode('utf-8'))
        return m.hexdigest()[:8] + os.path.splitext(url)[1]
723644
def decode(self, ids):
    """"""
    ids = text_encoder.pad_decr(ids)
    subword_ids = ids
    del ids

    subwords = []

    # Some ids correspond to bytes. Because unicode characters are composed of
    # possibly multiple bytes, we attempt to decode contiguous lists of bytes
    # all together. Invalid byte sequences are replaced with the unicode
    # replacement (i.e. unknown) character U+FFFD.
    prev_bytes = []

    def consume_prev_bytes():
      if prev_bytes:
        bytestr = b"".join(prev_bytes)
        bytes_text = bytestr.decode("utf-8", "replace")
        subwords.append(bytes_text)
      return []

    for subword_id in subword_ids:
      subword = self._id_to_subword(subword_id)
      if isinstance(subword, six.binary_type):
        # Byte-encoded
        prev_bytes.append(subword)
      else:
        # If there were bytes previously, convert to unicode.
        prev_bytes = consume_prev_bytes()
        trimmed, add_space = _trim_underscore_and_tell(subword)
        subwords.append(trimmed)
        if add_space:
          subwords.append(" ")
    # If there were trailing bytes, convert to unicode.
    prev_bytes = consume_prev_bytes()

    return tf.compat.as_text("".join(subwords))
1305078
def md5(string, n=32, encoding="utf-8", skip_encode=False):
    
    todo = string if skip_encode else unicode(string).encode(encoding)
    if n == 32:
        return hashlib.md5(todo).hexdigest()
    elif isinstance(n, (int, float)):
        return hashlib.md5(todo).hexdigest()[(32 - n) // 2 : (n - 32) // 2]
    elif isinstance(n, (tuple, list)):
        return hashlib.md5(todo).hexdigest()[n[0] : n[1]]
1203675
def md5sum(data):
    
    if six.PY3:  # pragma: no cover
        return hashlib.md5(data.encode('utf-8')).hexdigest()
    else:  # pragma: no cover
        return hashlib.md5(data).hexdigest()
791345
def tohu_id(self):
        
        myhash = hashlib.md5(str(id(self)).encode()).hexdigest()
        return myhash[:12]
1068747
def md5(self):
        """"""
        return hashlib.md5('_'.join([self.CHROM, str(self.POS), self.REF,
                                     self.ALT])).hexdigest()
1039980
def fuid(path = nil)
      if @uid.nil? && path.nil?
        1
      else
        @uid || Digest::MD5.hexdigest(path).to_i(16) % 10000
      end
    end
998570
def get_full_md5(self, partial_md5, collection):
        """"""
        print 'Notice: Performing slow md5 search...'
        starts_with = '%s.*' % partial_md5
        sample_info = self.database[collection].find_one({'md5': {'$regex' : starts_with}},{'md5':1})
        return sample_info['md5'] if sample_info else None
814428
def get_md5_from_metadata(ase):
    # type: (blobxfer.models.azure.StorageEntity) -> str
    
    # if encryption metadata is present, check for pre-encryption
    # md5 in blobxfer extensions
    md5 = None
    if ase.is_encrypted:
        try:
            md5 = ase.encryption_metadata.blobxfer_extensions.\
                pre_encrypted_content_md5
        except AttributeError:
            # this can happen if partial metadata is present
            md5 = None
    if blobxfer.util.is_none_or_empty(md5):
        md5 = ase.md5
    return md5
444231
static String md5(String origin) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(origin.getBytes("UTF-8"));
      BigInteger bi = new BigInteger(1, md.digest());
      StringBuilder hash = new StringBuilder(bi.toString(16));

      while (hash.length() < 32) {
        hash.insert(0, "0");
      }

      return hash.toString();
    } catch (Exception e) {
      return getUuid();
    }
  }
118503
def _post_md5_skip_on_check(self, key, filename, size, md5_match):
        # type: (Downloader, str, str, int, bool) -> None
        
        with self._md5_meta_lock:
            rfile = self._md5_map.pop(key)
        lpath = pathlib.Path(filename)
        if md5_match:
            if size is None:
                size = lpath.stat().st_size
            with self._transfer_lock:
                self._transfer_set.remove(
                    blobxfer.operations.download.Downloader.
                    create_unique_transfer_operation_id(rfile))
                self._download_total -= 1
                self._download_bytes_total -= size
            if self._general_options.dry_run:
                logger.info('[DRY RUN] MD5 match, skipping: {} -> {}'.format(
                    rfile.path, lpath))
        else:
            if self._general_options.dry_run:
                with self._transfer_lock:
                    self._transfer_set.remove(
                        blobxfer.operations.download.Downloader.
                        create_unique_transfer_operation_id(rfile))
                    self._download_total -= 1
                    self._download_bytes_total -= size
                logger.info(
                    '[DRY RUN] MD5 mismatch, download: {} -> {}'.format(
                        rfile.path, lpath))
            else:
                self._add_to_download_queue(lpath, rfile)
648440
def find_raw(self, file_id):
        """"""
        raw_handler = lambda resp, data: data
        return self.transport.GET(url='/file/%d/raw' % file_id, handler=raw_handler)
1072343
def md5(text):
    """"""

    h = hashlib.md5()
    h.update(_unicode(text).encode("utf-8"))

    return h.hexdigest()
652894
function getMD5text(part) {
    var message = '';
    var constants = part.constants.map(function(field) {
      return field.type + ' ' + field.name + '=' + field.raw;
    }).join('\n');

    var fields = part.fields.map(function(field) {
      if (field.messageType) {
        return field.messageType.md5 + ' ' + field.name;
      }
      else {
        return field.type + ' ' + field.name;
      }
    }).join('\n');

    message += constants;
    if (message.length > 0 && fields.length > 0) {
      message += "\n";
    }
    message += fields;
    return message;
  }
1175932
def get_md5_hash(file_path):
    
    checksum = hashlib.md5()
    with open(file_path, 'rb') as f:
        for chunk in iter(lambda: f.read(128 * checksum.block_size), b''):
            checksum.update(chunk)
    return checksum.hexdigest()