Returns a SHA-1 hash of {@code s}.
516440
public static ByteString sha1(ByteString s) {
    try {
      MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
      byte[] sha1Bytes = messageDigest.digest(s.toByteArray());
      return ByteString.of(sha1Bytes);
    } catch (NoSuchAlgorithmException e) {
      throw new AssertionError(e);
    }
  }
1272886
def get_file_sha1(filename_or_io):
    '''
    
    '''

    file_data = get_file_io(filename_or_io)
    cache_key = file_data.cache_key

    if cache_key and cache_key in FILE_SHAS:
        return FILE_SHAS[cache_key]

    with file_data as file_io:
        hasher = sha1()
        buff = file_io.read(BLOCKSIZE)

        while len(buff) > 0:
            if isinstance(buff, six.text_type):
                buff = buff.encode('utf-8')

            hasher.update(buff)
            buff = file_io.read(BLOCKSIZE)

    digest = hasher.hexdigest()

    if cache_key:
        FILE_SHAS[cache_key] = digest

    return digest
812457
public Iterable<ArchiveModel> findBySHA1(String sha1)
    {
        List<Vertex> query = getGraphContext().getGraph().traversal()
            .V()
            .property(FileModel.SHA1_HASH, sha1)
            .property(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, ArchiveModel.TYPE)
            .toList();

        return new FramedVertexIterable<>(getGraphContext().getFramed(), query, ArchiveModel.class);
    }
1117613
public static String shaBase64(String s) {
    try {
      MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
      byte[] sha1Bytes = messageDigest.digest(s.getBytes("UTF-8"));
      return ByteString.of(sha1Bytes).base64();
    } catch (NoSuchAlgorithmException e) {
      throw new AssertionError(e);
    } catch (UnsupportedEncodingException e) {
      throw new AssertionError(e);
    }
  }
1131032
@Nullable
    static String shaHashInput(@Nullable String toHash) {
        if (StripeTextUtils.isBlank(toHash)) {
            return null;
        }

        try {
            final MessageDigest digest = MessageDigest.getInstance("SHA-1");
            final byte[] bytes = toHash.getBytes("UTF-8");
            digest.update(bytes, 0, bytes.length);
            return bytesToHex(digest.digest());
        } catch (NoSuchAlgorithmException noSuchAlgorithm) {
            return null;
        } catch (UnsupportedEncodingException unsupportedCoding) {
            return null;
        }
    }
23767
def _string_hash(s):
    """"""
    h = 5381
    for c in s:
        h = h * 33 + ord(c)
    return h
660092
private String hash(String string) {
        final String sha1Hex = DigestUtils.sha1Hex(string);
        return StringUtils.substring(sha1Hex, 0, 8);
    }
339159
function hash(s) {
    var h = hash.BASE

    for (var i = 0, l = s.length; i < l; i++) {
        h ^= s.charCodeAt(i)
        h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24)
    }

    return h >>> 0
}
654749
public function getSHA1()
    {
        try {
            $array = func_get_args();
            sort($array, SORT_STRING);

            return sha1(implode($array));
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_CALC_SIGNATURE);
        }
    }
486614
private static int normalizedHash(int hash, String s) {
    int nextHash = 0;
    for (int index = 0; index < s.length(); index++) {
      char ch = s.charAt(index);
      nextHash = 31 * nextHash + ch;
      if (ch == '%') {
        // hash next 2 characters
        index++;
        nextHash = 31 * nextHash + URIUtils.toLower(s.charAt(index));
        index++;
        nextHash = 31 * nextHash + URIUtils.toLower(s.charAt(index));
      }
    }
    // similar to Arrays.hashCode
    return hash * 31 + nextHash;
  }
1086240
def git_hash(blob):
    """"""
    head = str("blob " + str(len(blob)) + "\0").encode("utf-8")
    return sha1(head + blob).hexdigest()
1033376
public static byte[] stringToHash(String s) {
        if (s.length() % 2 != 0) {
            throw new IllegalArgumentException("Invalid hash string: " + s);
        }
        byte[] hash = new byte[s.length() / 2];
        for (int i = 0; i < s.length(); i += 2) {
            byte b = (byte) ((hexDigitValue(s.charAt(i)) << 4) + hexDigitValue(s.charAt(i + 1)));
            hash[i / 2] = b;
        }
        return hash;
    }
397970
public static byte[] sha1(@NotNull String input) {
		return digest(input.getBytes(Charsets.UTF_8), get(SHA_1_DIGEST), null, 1);
	}
190555
public static String hash(final String str)
        {
        try
            {
            final MessageDigest md = new Sha1();
            final byte[] hashed = md.digest(str.getBytes("UTF-8"));
            final byte[] encoded = Base64.encodeBase64(hashed);
            return new String(encoded, "UTF-8");
            }
        catch (final UnsupportedEncodingException e)
            {
            LOG.error("Encoding error??", e);
            return "";
            }
        }
1061198
public static String hashSHA( String str ) {
        byte[] b = str.getBytes();
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance( "SHA1" );
            md.update( b );
        }
        catch ( NoSuchAlgorithmException e ) {
            e.printStackTrace();
            // it's got to be there
        }
        return toHexString( md.digest() );
    }
844502
@Override
    public String hexSHA1(String value) {
        return String.valueOf(Hex.encodeHex(sha1(value)));
    }
1063174
public static String hash(Serializable obj) {

		if (obj == null) {
			return "";
		}
		StringBuilder hexString = new StringBuilder();
		try {

			MessageDigest m = MessageDigest.getInstance("SHA1");
			m.update(SerializationUtils.serialize(obj));

			byte[] mdbytes = m.digest();

            for (byte mdbyte : mdbytes) {
                hexString.append(Integer.toHexString(0xFF & mdbyte));
            }

		} catch (NoSuchAlgorithmException e) {
			return "";
		}
		return hexString.toString();
	}