Base32 encoded SHA1 info hash
498428
def infohash_base32(self):
        """"""
        self.validate()
        info = self.convert()[b'info']
        return b32encode(sha1(bencode(info)).digest())
142696
function hmacSha1 (options) {
  return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64')
}
720039
def hmac_sha1_signature
      # hmac secret is same as plaintext signature 
      secret = plaintext_signature
      Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, secret, signature_base)).gsub(/\n/, '')
    end
963713
protected byte[] EMSA_PKCS1_V1_5_ENCODE_HASH(byte[] h, int emLen, String algorithm) throws NoSuchAlgorithmException {

        // Check m
        if (h == null || h.length == 0) {
            throw new IllegalArgumentException("m");
        }

        byte[] algorithmPrefix = null;

        // Check algorithm
        if (Strings.isNullOrWhiteSpace(algorithm)) {
            throw new IllegalArgumentException("algorithm");
        }

        // Only supported algorithms
        if (algorithm.equals("SHA-256")) {

            // Initialize prefix and digest
            algorithmPrefix = SHA_256_PREFIX;

            if (h.length != 32) {
                throw new IllegalArgumentException("h is incorrect length for SHA-256");
            }
        } else {
            throw new IllegalArgumentException("algorithm");
        }


        // Construct t, the DER encoded DigestInfo structure
        byte[] t = new byte[algorithmPrefix.length + h.length];

        System.arraycopy(algorithmPrefix, 0, t, 0, algorithmPrefix.length);
        System.arraycopy(h, 0, t, algorithmPrefix.length, h.length);

        if (emLen < t.length + 11) {
            throw new IllegalArgumentException("intended encoded message length too short");
        }

        // Construct ps
        byte[] ps = new byte[emLen - t.length - 3];

        for (int i = 0; i < ps.length; i++) {
            ps[i] = (byte) 0xff;
        }

        // Construct em
        byte[] em = new byte[ps.length + t.length + 3];

        em[0] = 0x00; em[1] = 0x01; em[ps.length + 2] = 0x00;

        System.arraycopy(ps, 0, em, 2, ps.length);
        System.arraycopy(t, 0, em, ps.length + 3, t.length);

        return em;
    }
9621
def binary_encode_any_high_ascii_in_hash(hash)
      Hash[hash.map { |key, value| [key, binary_encode_any_high_ascii(value)] }]
    end
1342509
private static byte[] decodeBase64Digest(String base64Digest) {
        String expectedPrefix = "sha1-";
        if (!base64Digest.startsWith(expectedPrefix)) {
            throw new IllegalArgumentException(base64Digest + " did not start with " +
                    expectedPrefix);
        }
        base64Digest = base64Digest.replaceFirst(expectedPrefix, "");
        byte[] bytes = new byte[0];
        try {
            bytes = Base64.decode(base64Digest);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
        return bytes;
    }
962681
private static String convertToStandardName(String internalName) {
        if (internalName.equals("SHA")) {
            return "SHA-1";
        } else if (internalName.equals("SHA224")) {
            return "SHA-224";
        } else if (internalName.equals("SHA256")) {
            return "SHA-256";
        } else if (internalName.equals("SHA384")) {
            return "SHA-384";
        } else if (internalName.equals("SHA512")) {
            return "SHA-512";
        } else {
            return internalName;
        }
    }
1016358
def sha1sum(filename):
    
    sha1 = hashlib.sha1()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(128 * sha1.block_size), b''):
            sha1.update(chunk)
    return sha1.hexdigest()
204200
public static long decodeBase32(String hash) {
        boolean isNegative = hash.startsWith("-");
        int startIndex = isNegative ? 1 : 0;
        long base = 1;
        long result = 0;
        for (int i = hash.length() - 1; i >= startIndex; i--) {
            int j = getCharIndex(hash.charAt(i));
            result = result + base * j;
            base = base * 32;
        }
        if (isNegative)
            result *= -1;
        return result;
    }
644358
def RawBytesToScriptHash(raw):
        
        rawh = binascii.unhexlify(raw)
        rawhashstr = binascii.unhexlify(bytes(Crypto.Hash160(rawh), encoding='utf-8'))
        return UInt160(data=rawhashstr)
373532
function SHA1(source) { // @arg String - source string
                        // @ret SHA1HashHexString
//{@dev
    $valid($type(source, "String"), SHA1, "source");
//}@dev

    var sha1 = DataType["Array"]["toHexStringArray"](
                    SHA1_encode(
                        DataType["Uint8Array"]["fromString"](source) ) );

    return sha1.join("");
}
527220
def sha_hash(self) -> str:
        
        return hashlib.sha256(self.signed_raw().encode("ascii")).hexdigest().upper()
727828
public static String sha1( String string ) {
        try {
            byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes());
            return SecureHash.asHexString(sha1);
        } catch (NoSuchAlgorithmException e) {
            throw new SystemFailureException(e);
        }
    }
732227
def scramble_caching_sha2(password, nonce):
    # (bytes, bytes) -> bytes
    
    if not password:
        return b''

    p1 = hashlib.sha256(password).digest()
    p2 = hashlib.sha256(p1).digest()
    p3 = hashlib.sha256(p2 + nonce).digest()

    res = bytearray(p1)
    if PY2:
        p3 = bytearray(p3)
    for i in range(len(p3)):
        res[i] ^= p3[i]

    return bytes(res)
129068
def file_sha1(path):
  
  sha1 = hashlib.sha1()
  with open(path, "rb") as f:
    while True:
      block = f.read(2 ** 10)
      if not block:
        break
      sha1.update(block)
    return sha1.hexdigest()
273129
function hashUUID(hashFn, options, buffer, offset) {
	var i, v;
	var output = buffer || new Buffer(16);
	offset = offset || 0;
	options = options || {};

	if (!options.data) {
		for (i=0; i<16; i++) {
			output[i] = 0;
		}
		return buffer || unparse(output);
	}

	if (typeof options.ns === 'string') {
		options.ns = parse(options.ns, new Buffer(16));
	}

	var hasher = crypto.createHash(hashFn);
	hasher.update(options.ns || '');
	hasher.update(options.data || '');

	switch (hashFn) {
		case 'md5': v = 0x30; break;
		case 'sha1': v = 0x50; break;
	}
	output.write(hasher.digest('binary'), offset, 16, 'binary');
	output[offset + 8] = output[offset + 8] & 0x3f | 0x80; // set variant
	output[offset + 6] = output[offset + 6] & 0x0f | v; // set version

	return buffer || unparse(output);
}
990653
public static String sha1(InputStream is) {
		byte[] buf = new byte[1024*1024*5];
		int bytesRead = 0;
		MessageDigest md;
		try {
			md = MessageDigest.getInstance("SHA1");
		} catch (NoSuchAlgorithmException nsae) {
			throw new RuntimeIOException(nsae.getMessage(), nsae);
		}
		try {
			while ((bytesRead = is.read(buf)) > 0) {
				md.update(buf, 0, bytesRead);
			}
		} catch (IOException ioe) {
			throw new RuntimeIOException(ioe.getMessage(), ioe);
		}
		byte[] digest = md.digest();
		String hexDigest = new String(Hex.encodeHex(digest));
		return hexDigest;
	}