Generate the initial security hash from self.content_object
        and a (unix) timestamp.
762553
def initial_security_hash(self, timestamp):
        

        initial_security_dict = {
            'content_type': str(self.target_object._meta),
            'object_pk': str(self.target_object._get_pk_val()),
            'timestamp': str(timestamp),
        }
        return self.generate_security_hash(**initial_security_dict)
901237
def generate_security_hash(self, content_type, object_pk, timestamp):
        
        info = (content_type, object_pk, timestamp)
        key_salt = "django.contrib.forms.CommentSecurityForm"
        value = "-".join(info)
        return salted_hmac(key_salt, value).hexdigest()
607070
def hash(self):
        """"""
        if self._hash is None:
            m = hashlib.new('md5')
            if self._preprocessor is None:
                # generate hash from numpy array
                m.update(numpy_buffer(self._X_train))
                m.update(numpy_buffer(self._y_train))
                if self._X_test is not None:
                    m.update(numpy_buffer(self._X_test))
                if self._y_test is not None:
                    m.update(numpy_buffer(self._y_test))
            elif callable(self._preprocessor):
                # generate hash from user defined object (source code)
                m.update(inspect.getsource(self._preprocessor).encode('utf-8'))

            self._hash = m.hexdigest()

        return self._hash
1374410
def get_content_version(cls, abspath: str) -> str:
        
        data = cls.get_content(abspath)
        hasher = hashlib.md5()
        if isinstance(data, bytes):
            hasher.update(data)
        else:
            for chunk in data:
                hasher.update(chunk)
        return hasher.hexdigest()
304519
def create_NT_hashed_password_v1(passwd, user=None, domain=None):
    ""
    # if the passwd provided is already a hash, we just return the second half
    if re.match(r'^[\w]{32}:[\w]{32}$', passwd):
        return binascii.unhexlify(passwd.split(':')[1])

    digest = hashlib.new('md4', passwd.encode('utf-16le')).digest()
    return digest
731329
def encrypted_to(self, raw_data):
        """"""
        # TODO: make this support multiple keys.
        result = self._gpg.list_packets(raw_data)
        if not result.key:
            raise LookupError(
                "Content is not encrypted to a GnuPG key!")
        try:
            return self.find_key_by_keyid(result.key)
        except:
            return self.find_key_by_subkey(result.key)
203322
private function generateInitialHash()
    {
        $mergedString = $this->isLive . $this->transaction['orderId'] . $this->transaction['invoiceNumber'] .
            $this->transaction['amount'] . $this->customer['telephoneNumber'] . $this->customer['email'] .
            $this->vendorId . $this->currency . $this->payloads['payload1'] . $this->payloads['payload2'] .
            $this->payloads['payload3'] . $this->payloads['payload4'] . $this->callback .
            $this->customer['sendEmail'] . $this->callbackMode;

        return hash_hmac('sha1', $mergedString, $this->hashKey);
    }
984578
def GenerateCSRFToken(user_id, time):
  """"""
  precondition.AssertType(user_id, Text)
  precondition.AssertOptionalType(time, int)

  time = time or rdfvalue.RDFDatetime.Now().AsMicrosecondsSinceEpoch()

  secret = config.CONFIG.Get("AdminUI.csrf_secret_key", None)
  # TODO(amoser): Django is deprecated. Remove this at some point.
  if not secret:
    secret = config.CONFIG["AdminUI.django_secret_key"]
  digester = hmac.new(secret.encode("ascii"), digestmod=hashlib.sha256)
  digester.update(user_id.encode("ascii"))
  digester.update(CSRF_DELIMITER)
  digester.update(str(time).encode("ascii"))
  digest = digester.digest()

  token = base64.urlsafe_b64encode(b"%s%s%d" % (digest, CSRF_DELIMITER, time))
  return token.rstrip(b"=")
1152386
def calculate_payload_hash(payload, algorithm, content_type):
    """"""
    p_hash = hashlib.new(algorithm)

    parts = []
    parts.append('hawk.' + str(HAWK_VER) + '.payload\n')
    parts.append(parse_content_type(content_type) + '\n')
    parts.append(payload or '')
    parts.append('\n')

    for i, p in enumerate(parts):
        # Make sure we are about to hash binary strings.
        if not isinstance(p, six.binary_type):
            p = p.encode('utf8')
        p_hash.update(p)
        parts[i] = p

    log.debug('calculating payload hash from:\n{parts}'
              .format(parts=pprint.pformat(parts)))

    return b64encode(p_hash.digest())
254382
function objectHash(obj) {
	var hash = crypto.createHash('md5');
	hash.update(makeHashKey(obj));
	return hash.digest('hex');
}
23173
def hash(self, key, message=None):
		
		hmac_obj = hmac.HMAC(key, self.__digest_generator, backend=default_backend())
		if message is not None:
			hmac_obj.update(message)
		return hmac_obj.finalize()
423020
def compute_payload_block_hash(this):
    """"""

    return hmac.new(
        hashlib.sha512(
            struct.pack('<Q', this._index) +
            hashlib.sha512(
                this._._.header.value.dynamic_header.master_seed.data +
                this._.transformed_key + b'\x01'
            ).digest()
        ).digest(),
        struct.pack('<Q', this._index) +
        struct.pack('<I', len(this.block_data)) +
        this.block_data, hashlib.sha256
    ).digest()
751261
def get_content_hash(self):
        
        if not self.rexists():
            return SCons.Util.MD5signature('')
        fname = self.rfile().get_abspath()
        try:
            cs = SCons.Util.MD5filesignature(fname,
                chunksize=SCons.Node.FS.File.md5_chunksize*1024)
        except EnvironmentError as e:
            if not e.filename:
                e.filename = fname
            raise
        return cs
1170958
def to_hash
      characteristics.inject({}) do |memo, (k, v)|
        memo[k] = v.value
        memo
      end
    end
1138125
function hash (str) {
  return crypto
    .createHash('sha1')
    .update(str, 'ascii')
    .digest('base64')
    .replace(PLUS_GLOBAL_REGEXP, '-')
    .replace(SLASH_GLOBAL_REGEXP, '_')
    .replace(EQUAL_GLOBAL_REGEXP, '')
}
1323170
def create_from_hash(hash, ezo):
        '''
        
        '''

        cp, err = ezo.db.get("contracts", hash)
        if err:
            return None, err

        # create a new Contract
        c = Contract(cp["name"], ezo)
        c.abi = cp["abi"]
        c.bin = cp["bin"]
        c.hash = cp["hash"]
        c.source = cp["source"]
        c.timestamp = cp["timestamp"]
        c.te_map = cp['te-map']

        return c, None
1063298
def generate_nt_hash(password):
    '''
    
    '''
    return binascii.hexlify(
        hashlib.new(
            'md4',
            password.encode('utf-16le')
        ).digest()
    ).upper()