Looks for a torrent with the given info-hash. In case there is such
a torrent in the session, a {@link TorrentHandle} to that torrent
is returned.
<p>
In case the torrent cannot be found, a null is returned.

@param infoHash
@return
330819
public TorrentHandle findTorrent(Sha1Hash infoHash) {
        torrent_handle th = s.find_torrent(infoHash.swig());

        return th != null && th.is_valid() ? new TorrentHandle(th) : null;
    }
1112932
def setDownloadRateLimit(infoHash, bytesPerSecond)
      torrentData = @torrentData[infoHash]
      if ! torrentData
        @logger.warn "Asked to set download rate limit for a non-existent torrent #{QuartzTorrent.bytesToHex(infoHash)}"
        return
      end
 
      if bytesPerSecond
        if ! torrentData.downRateLimit
          torrentData.downRateLimit = RateLimit.new(bytesPerSecond, 2*bytesPerSecond, 0)
        else
          torrentData.downRateLimit.unitsPerSecond = bytesPerSecond
        end
      else
        torrentData.downRateLimit = nil
      end

      torrentData.peers.all.each do |peer|
        withPeersIo(peer, "setting download rate limit") do |io|
          io.readRateLimit = torrentData.downRateLimit
        end
      end
     
    end
433953
public static TermColor getColorByHash(String hash) {

    	if(hash==null)
    		throw new IllegalArgumentException("Invalid hash value (null) for color construction");
    	
    	// lowercase and remove hash character, if any
    	hash = hash.toLowerCase().replaceAll("^#", "");
    	
    	// color written in #ABC format
        if(hash.matches("^[0-9a-f]{3}$")) {
            String r = hash.substring(0, 1);
            String g = hash.substring(1, 2);
            String b = hash.substring(2, 3);
            return new TermColorImpl(Integer.parseInt(r+r, 16), Integer.parseInt(g+g, 16), Integer.parseInt(b+b, 16));
        }
        // color written in #AABBCC format
        else if(hash.matches("^[0-9a-f]{6}$")) {
            String r = hash.substring(0, 2);
            String g = hash.substring(2, 4);
            String b = hash.substring(4, 6);
            return new TermColorImpl(Integer.parseInt(r, 16), Integer.parseInt(g, 16), Integer.parseInt(b, 16));
        }
        // invalid hash
        return null;
    }
617517
function getDataTorrentFromFile(torrentFile) {
  if(!fs.existsSync(torrentFile)) {
    throw new Error(`This torrent file does not exists : ${torrentFile}`);
  }

  const torrent = parseTorrent(fs.readFileSync(torrentFile));
  torrent.path = torrentFile;
  torrent.hash = torrent.infoHash.toUpperCase();
  return torrent;
}
314711
function getInfo(hash) {
  const info = getHashInfo(hash);
  const algo = getAlgorithmFromId(info.id);
  info.algorithm = algo.name;
  info.options = algo.getOptions(hash, info);

  return info;
}
558499
public String decodeHex(String hash) {
        final StringBuilder result  = new StringBuilder();
        final long[]        numbers = this.decode(hash);

        for (final long number : numbers) {
            result.append(Long.toHexString(number).substring(1));
        }

        return result.toString();
    }
704720
func (cl *Client) AddTorrentInfoHashWithStorage(infoHash metainfo.Hash, specStorage storage.ClientImpl) (t *Torrent, new bool) {
	cl.lock()
	defer cl.unlock()
	t, ok := cl.torrents[infoHash]
	if ok {
		return
	}
	new = true

	t = cl.newTorrent(infoHash, specStorage)
	cl.eachDhtServer(func(s *dht.Server) {
		go t.dhtAnnouncer(s)
	})
	cl.torrents[infoHash] = t
	cl.clearAcceptLimits()
	t.updateWantPeersEvent()
	// Tickle Client.waitAccept, new torrent may want conns.
	cl.event.Broadcast()
	return
}
855645
private static String getListInstanceHash(HttpServletRequest request) {

        String result;
        if ((request != null) && (request.getSession(false) != null)) {
            result = "_" + String.valueOf(request.getSession(false).getId().hashCode());

        } else {
            result = "";
        }
        return result;
    }
511395
public String getAvatarHash() {
        byte[] bytes = getAvatar();
        if (bytes == null) {
            return null;
        }

        MessageDigest digest;
        try {
            digest = MessageDigest.getInstance("SHA-1");
        }
        catch (NoSuchAlgorithmException e) {
            LOGGER.log(Level.SEVERE, "Failed to get message digest", e);
            return null;
        }

        digest.update(bytes);
        return StringUtils.encodeHex(digest.digest());
    }
845228
public final DataHash getDecodedDataHash() throws TLVParserException {
        byte[] content = getContent();
        if (DataHash.isDataHash(content)) {
            return new DataHash(content);
        }
        throw new TLVParserException("Invalid DataHash content");
    }
1326278
def info_hash(self):
        """"""
        info = self._struct.get('info')

        if not info:
            return None

        return sha1(Bencode.encode(info)).hexdigest()
604947
public final DataHash getHash() {
        if (outputHash == null) {
            byte[] hash = messageDigest.digest();
            outputHash = new DataHash(algorithm, hash);
        }
        return outputHash;
    }
1228601
public String name() {
        torrent_status ts = th.status(torrent_handle.query_name);
        return ts.getName();
    }
298672
def handlePause(infoHash, value)
      torrentData = @torrentData[infoHash]
      if ! torrentData
        @logger.warn "Asked to pause a non-existent torrent #{QuartzTorrent.bytesToHex(infoHash)}"
        return
      end

      return if torrentData.paused == value

      torrentData.paused = value

      if !value
        # On unpause, queue the torrent since there might not be room for it to run.
        # Make sure it goes to the head of the queue.
        queue(torrentData, :unshift)
      end

      setFrozen infoHash, value if ! torrentData.queued

      dequeue
    end
1084711
@Nullable
    public Map<Sha256Hash, Integer> getAppearsInHashes() {
        return appearsInHashes != null ? ImmutableMap.copyOf(appearsInHashes) : null;
    }
347336
def requestMetadataPieces(infoHash)
      torrentData = @torrentData[infoHash]
      if ! torrentData
        @logger.error "Request metadata pices: torrent data for torrent #{QuartzTorrent.bytesToHex(infoHash)} not found."
        return
      end
      
      return if torrentData.paused || torrentData.queued

      # We may not have completed the extended handshake with the peer which specifies the torrent size.
      # In this case torrentData.metainfoPieceState is not yet set.
      return if ! torrentData.metainfoPieceState

      @logger.info "#{QuartzTorrent.bytesToHex(infoHash)}: Obtained all pieces of metainfo." if torrentData.metainfoPieceState.complete?

      pieces = torrentData.metainfoPieceState.findRequestablePieces
      classifiedPeers = ClassifiedPeers.new torrentData.peers.all
      peers = torrentData.metainfoPieceState.findRequestablePeers(classifiedPeers)
  
      if peers.size > 0
        # For now, just request all pieces from the first peer.
        pieces.each do |pieceIndex|
          msg = ExtendedMetaInfo.new
          msg.msgType = :request
          msg.piece = pieceIndex
          withPeersIo(peers.first, "requesting metadata piece") do |io|
            sendMessageToPeer msg, io, peers.first
            torrentData.metainfoPieceState.setPieceRequested(pieceIndex, true)
            @logger.debug "#{QuartzTorrent.bytesToHex(infoHash)}: Requesting metainfo piece from #{peers.first}: piece #{pieceIndex}"
          end
        end
      else
        @logger.error "#{QuartzTorrent.bytesToHex(infoHash)}: No peers found that have metadata."
      end

    end
130727
public static HashAlgorithm getHashAlgorithm(String hashAlgorithm) {
	if (hashAlgorithm==null) {
		return null;
	}
	switch (hashAlgorithm) {
		case "md2": return HashAlgorithm.md2;
		case "md4": return HashAlgorithm.md4;
		case "md5": return HashAlgorithm.md5;
		case "none": return HashAlgorithm.none;
		case "ripemd128": return HashAlgorithm.ripemd128;
		case "ripemd160": return HashAlgorithm.ripemd160;
		case "sha1": return HashAlgorithm.sha1;
		case "sha224": return HashAlgorithm.sha224;
		case "sha256": return HashAlgorithm.sha256;
		case "sha384": return HashAlgorithm.sha384;
		case "sha512": return HashAlgorithm.sha512;
		case "whirlpool": return HashAlgorithm.whirlpool;
		default:
			LOG.error("Uknown hash algorithm: \""+hashAlgorithm+"\"");
			break;
	}
	return null;
}