turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
        using PKCS1's \"emsa-pkcs1-v1_5\" encoding.  totally bizarre.
172426
def _pkcs1imify(self, data):
        
        size = len(util.deflate_long(self.n, 0))
        filler = max_byte * (size - len(SHA1_DIGESTINFO) - len(data) - 3)
        return zero_byte + one_byte + filler + zero_byte + SHA1_DIGESTINFO + data
790951
def _dhash(self, params):
        """"""
        m = hashlib.new('md5')
        m.update(self.hash.encode('utf-8'))
        for key in sorted(params.keys()):
            h_string = ('%s-%s' % (key, params[key])).encode('utf-8')
            m.update(h_string)
        return m.hexdigest()
746728
def hmac_md5(s, salt):
        
        hmac_md5 = hmac.new(salt.encode('utf-8'), s.encode('utf-8'),
                            digestmod=hashlib.md5).hexdigest()
        return hmac_md5
1078395
def encode_w_salt(self, salt, key):
        
        enc_key = '%s%s' % (salt, key)
        enc_val = hashlib.sha1(enc_key).hexdigest()
        return "sha1:%s$%s" % (salt, enc_val)
816641
function sha1(str) {
	      var utf8 = utf8Encode(str);
	      var words32 = stringToWords32(utf8);
	      var len = utf8.length * 8;
	      var w = new Array(80);
	      var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
	      words32[len >> 5] |= 0x80 << (24 - len % 32);
	      words32[((len + 64 >> 9) << 4) + 15] = len;
	      for (var i = 0; i < words32.length; i += 16) {
	          var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
	          for (var j = 0; j < 80; j++) {
	              if (j < 16) {
	                  w[j] = words32[i + j];
	              }
	              else {
	                  w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
	              }
	              var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
	              var temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
	              _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
	          }
	          _e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4];
	      }
	      var sha1 = words32ToString([a, b, c, d, e]);
	      var hex = '';
	      for (var i = 0; i < sha1.length; i++) {
	          var b_1 = sha1.charCodeAt(i);
	          hex += (b_1 >>> 4 & 0x0f).toString(16) + (b_1 & 0x0f).toString(16);
	      }
	      return hex.toLowerCase();
	      var _d, _e;
	  }
67462
def hash64(data: Any, seed: int = 0) -> int:
    
    # -------------------------------------------------------------------------
    # MurmurHash3
    # -------------------------------------------------------------------------
    c_data = to_str(data)
    if mmh3:
        c_signed_low, _ = mmh3.hash64(data, seed=seed, x64arch=IS_64_BIT)
        return c_signed_low
    py_data = to_bytes(c_data)
    py_signed_low, _ = pymmh3_hash64(py_data, seed=seed)
    return py_signed_low
294750
def hash64( key, seed = 0x0, x64arch = True ):
    '''  '''

    hash_128 = hash128( key, seed, x64arch )

    unsigned_val1 = hash_128 & 0xFFFFFFFFFFFFFFFF
    if unsigned_val1 & 0x8000000000000000 == 0:
        signed_val1 = unsigned_val1
    else:
        signed_val1 = -( (unsigned_val1 ^ 0xFFFFFFFFFFFFFFFF) + 1 )

    unsigned_val2 = ( hash_128 >> 64 ) & 0xFFFFFFFFFFFFFFFF
    if unsigned_val2 & 0x8000000000000000 == 0:
        signed_val2 = unsigned_val2
    else:
        signed_val2 = -( (unsigned_val2 ^ 0xFFFFFFFFFFFFFFFF) + 1 )

    return ( int( signed_val1 ), int( signed_val2 ) )
1256435
public static byte[] HmacSha1(byte[] binaryData, String key) throws Exception {
		try {
			Mac mac = Mac.getInstance(HMAC_SHA1);
			SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1);
			mac.init(secretKey);
			byte[] HmacSha1Digest = mac.doFinal(binaryData);
			return HmacSha1Digest;
			
		} catch (NoSuchAlgorithmException e) {
			LOG.error("mac not find algorithm {}", HMAC_SHA1);
			throw e;
		} catch (InvalidKeyException e) {
			LOG.error("mac init key {} occur a error {}", key, e.toString());
			throw e;
		} catch (IllegalStateException e) {
			LOG.error("mac.doFinal occur a error {}", e.toString());
			throw e;
		}
	}
575919
function sha256(data) {
    if (!data.byteLength) {
        return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));
    }
    if (subtle) {
        return subtle.digest({ name: 'SHA-256' }, data);
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var sha = nodeCrypto.createHash('sha256');
            var hash = sha.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));
    }
}
968855
def convert_to_hash(data)
      data.map do |item|
        item[:key].split('/').reverse.reduce(item[:value]) { |h, v| { v => h } }
      end.reduce(:deep_merge)
    end
1343645
function calculateBlobSha1(data) {
  return crypto.createHash('sha1').update(`blob ${data.length}\0`).update(data).digest('hex');
}
1174031
def hash_to_bytesuri(s):
    
    # TODO: we should pad string with zeros till closest 32 bytes word because of a bug in processReceipt (in snet_cli.contract.process_receipt)
    s = "ipfs://" + s
    return s.encode("ascii").ljust(32 * (len(s)//32 + 1), b"\0")
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)
438909
def FromPublicKey(cls, public_key):
    """"""
    # Our CN will be the first 64 bits of the hash of the public key
    # in MPI format - the length of the key in 4 bytes + the key
    # prefixed with a 0. This weird format is an artifact from the way
    # M2Crypto handled this, we have to live with it for now.
    n = public_key.GetN()
    raw_n = binascii.unhexlify("%x" % n)

    mpi_format = struct.pack(">i", len(raw_n) + 1) + b"\x00" + raw_n

    digest = binascii.hexlify(hashlib.sha256(mpi_format).digest()[:8])
    return cls("C.{}".format(digest.decode("ascii")))
948776
def hotp_truncate(hmac_result, length=6):
    
    if len(hmac_result) != 20:
        raise yubico_exception.YubicoError("HMAC-SHA-1 not 20 bytes long")
    offset   =  ord_byte(hmac_result[19]) & 0xf
    bin_code = (ord_byte(hmac_result[offset]) & 0x7f) << 24 \
        | (ord_byte(hmac_result[offset+1]) & 0xff) << 16 \
        | (ord_byte(hmac_result[offset+2]) & 0xff) <<  8 \
        | (ord_byte(hmac_result[offset+3]) & 0xff)
    return bin_code % (10 ** length)
67681
def jks_pkey_encrypt(key, password_str):
    
    password_bytes = password_str.encode('utf-16be') # Java chars are UTF-16BE code units
    iv = os.urandom(20)

    key = bytearray(key)
    xoring = zip(key, _jks_keystream(iv, password_bytes))
    data = bytearray([d^k for d,k in xoring])

    check = hashlib.sha1(bytes(password_bytes + key)).digest()
    return bytes(iv + data + check)
1272374
def dict_hash(dct):
    """"""
    dct_s = json.dumps(dct, sort_keys=True)

    try:
        m = md5(dct_s)
    except TypeError:
        m = md5(dct_s.encode())

    return m.hexdigest()