MCPcopy Index your code
hub / github.com/RustPython/RustPython / resolve_digestmod

Function resolve_digestmod

crates/stdlib/src/hashlib.rs:218–235  ·  view source on GitHub ↗
(digestmod: &PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

216 }
217
218 fn resolve_digestmod(digestmod: &PyObjectRef, vm: &VirtualMachine) -> PyResult<String> {
219 if let Some(name) = digestmod.downcast_ref::<PyStr>()
220 && let Some(name_str) = name.to_str()
221 {
222 return Ok(name_str.to_lowercase());
223 }
224 if let Ok(name_obj) = digestmod.get_attr("__name__", vm)
225 && let Some(name) = name_obj.downcast_ref::<PyStr>()
226 && let Some(name_str) = name.to_str()
227 && let Some(algo) = name_str.strip_prefix("openssl_")
228 {
229 return Ok(algo.to_owned());
230 }
231 Err(vm.new_exception_msg(
232 UnsupportedDigestmodError::static_type().to_owned(),
233 "unsupported digestmod".into(),
234 ))
235 }
236
237 fn hash_digest_size(name: &str) -> Option<usize> {
238 match name {

Callers 2

hmac_newFunction · 0.85
hmac_digestFunction · 0.85

Calls 7

to_strMethod · 0.80
to_lowercaseMethod · 0.80
strip_prefixMethod · 0.80
new_exception_msgMethod · 0.80
ErrClass · 0.50
get_attrMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected