Set algorithm ID and hexadecimal digest for next operation.
970765
def set_hash(self, algo, digest):
        """"""
        self.algo = algo
        self.digest = digest
1341285
public static String getFingerprint(byte[] encoded, String algorithm)
			throws SshException {

		Digest md5 = (Digest) ComponentManager.getInstance().supportedDigests()
				.getInstance(algorithm);

		md5.putBytes(encoded);

		byte[] digest = md5.doFinal();

		StringBuffer buf = new StringBuffer();
		int ch;
		for (int i = 0; i < digest.length; i++) {
			ch = digest[i] & 0xFF;
			if (i > 0) {
				buf.append(':');
			}
			buf.append(HEX[(ch >>> 4) & 0x0F]);
			buf.append(HEX[ch & 0x0F]);
		}

		return buf.toString();
	}
198218
public void setAlgorithm(KeyAgreementType dh) 
	{
		log("DH algorithm set: " + getDHName(dhMode) + " -> " + getDHName(dh));
		try {
			if(dhMode != null && dh.keyType == dhMode.keyType) return;
			dhMode = dh;
			switch (dhMode.keyType) {
		        case KeyAgreementType.DH_MODE_DH3K:
		    		DHParameterSpec paramSpec = new DHParameterSpec(dhP, dhG, DH_EXP_LENGTH);
		    		dhKeyGen = KeyPairGenerator.getInstance(ALGORITHM_DH);
		    		dhKeyGen.initialize(paramSpec, sr);
		    		dhKeyPair = dhKeyGen.generateKeyPair();
		    		clearEcdh();
		    		break;
		        case KeyAgreementType.DH_MODE_EC25:
		        	setupEC(256);
			        break;
		        case KeyAgreementType.DH_MODE_EC38:
		        default:
		        	setupEC(384);
			        break;
	        }
		} catch (Exception e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
	        throw new RuntimeException("Failed init Diffie-Hellman: " + e.getClass().getName() + ": " + e.getMessage() + ", bitlength p = " + dhP.bitCount());
        }
	}
149679
def pksign(self, conn):
        """"""
        log.debug('signing %r digest (algo #%s)', self.digest, self.algo)
        identity = self.get_identity(keygrip=self.keygrip)
        r, s = self.client.sign(identity=identity,
                                digest=binascii.unhexlify(self.digest))
        result = sig_encode(r, s)
        log.debug('result: %r', result)
        keyring.sendline(conn, b'D ' + result)
413413
def module_set_id(self) -> str:
        
        fnames = sorted(["@".join(m) for m in self.schema_data.modules])
        return hashlib.sha1("".join(fnames).encode("ascii")).hexdigest()
902543
def compute_hash(func, string):
    """"""
    h = func()
    h.update(string)
    return h.hexdigest()
119753
def prepare_cache_id(self, combined_args_kw):
        ""
        cache_id = "".join(self.id(a) for a in combined_args_kw)
        return cache_id
6146
def _compute_key(self, id, nbytes):
        """"""
        m = Message()
        m.add_mpint(self.K)
        m.add_bytes(self.H)
        m.add_byte(b(id))
        m.add_bytes(self.session_id)
        # Fallback to SHA1 for kex engines that fail to specify a hex
        # algorithm, or for e.g. transport tests that don't run kexinit.
        hash_algo = getattr(self.kex_engine, "hash_algo", None)
        hash_select_msg = "kex engine {} specified hash_algo {!r}".format(
            self.kex_engine.__class__.__name__, hash_algo
        )
        if hash_algo is None:
            hash_algo = sha1
            hash_select_msg += ", falling back to sha1"
        if not hasattr(self, "_logged_hash_selection"):
            self._log(DEBUG, hash_select_msg)
            setattr(self, "_logged_hash_selection", True)
        out = sofar = hash_algo(m.asbytes()).digest()
        while len(out) < nbytes:
            m = Message()
            m.add_mpint(self.K)
            m.add_bytes(self.H)
            m.add_bytes(sofar)
            digest = hash_algo(m.asbytes()).digest()
            out += digest
            sofar += digest
        return out[:nbytes]
519417
def set_default(eng, algorithms=0xFFFF):
    
    if not isinstance(eng,Engine):
        eng=Engine(eng)
    global default
    libcrypto.ENGINE_set_default(eng.ptr, c_int(algorithms))
    default = eng
667777
public Digester init(String algorithm, Provider provider) {
		if(null == provider) {
			this.digest = SecureUtil.createMessageDigest(algorithm);
		}else {
			try {
				this.digest = MessageDigest.getInstance(algorithm, provider);
			} catch (NoSuchAlgorithmException e) {
				throw new CryptoException(e);
			}
		}
		return this;
	}
651637
private static byte[] digest(final InputStream input, final String algorithm)
		throws IOException {
		try {
			MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
			final int bufferLength = 8 * 1024;
			byte[] buffer = new byte[bufferLength];
			int read = input.read(buffer, 0, bufferLength);

			while (read > -1) {
				messageDigest.update(buffer, 0, read);
				read = input.read(buffer, 0, bufferLength);
			}

			return messageDigest.digest();
		} catch (NoSuchAlgorithmException e) {
			throw new ImpossibleException(e);
		}
	}
997245
public static function Ds(int $keyTag, int $algorithm, string $digest, int $digestType = DS::DIGEST_SHA1)
    {
        $rdata = new DS();
        $rdata->setKeyTag($keyTag);
        $rdata->setAlgorithm($algorithm);
        $rdata->setDigest($digest);
        $rdata->setDigestType($digestType);

        return $rdata;
    }
852211
def create_hash(sequence)
      Digest::MD5.hexdigest(sequence).to_s + "-" + Time.now.to_f.to_s
    end
1248308
function updatehex(){
  var hex = hexinputfield;
  if(hexinputvalue != hex){
    updateall(hexinputtobin(hex));
    clearallinputs();
    hexinputfield = hex;
    hexinputvalue = hex;
  }
}
155934
def np_hash(a):
    """"""
    if a is None:
        return hash(None)
    # Ensure that hashes are equal whatever the ordering in memory (C or
    # Fortran)
    a = np.ascontiguousarray(a)
    # Compute the digest and return a decimal int
    return int(hashlib.sha1(a.view(a.dtype)).hexdigest(), 16)
1301614
private void digestInteger(MessageDigest digest, int value) {
        byte[] valueBytes = new byte[4];
        Util.numberToBytes(value, valueBytes, 0, 4);
        digest.update(valueBytes);
    }
1023150
def message_digest_key_set(keyid, algtype, enctype, enc)
      current_keyid = message_digest_key_id
      if keyid == default_message_digest_key_id && current_keyid != keyid
        config_set('interface_ospf', 'message_digest_key_set',
                   @interface.name, 'no', current_keyid,
                   '', '', '')
      elsif keyid != default_message_digest_key_id
        fail TypeError unless enc.is_a?(String)
        fail ArgumentError unless enc.length > 0
        enctype = Encryption.symbol_to_cli(enctype)
        config_set('interface_ospf', 'message_digest_key_set',
                   @interface.name, '', keyid, algtype, enctype, enc)
      end
    end