deno/cli/checksum.rs
2020-09-21 08:26:41 -04:00

16 lines
382 B
Rust

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
pub fn gen(v: &[&[u8]]) -> String {
let mut ctx = ring::digest::Context::new(&ring::digest::SHA256);
for src in v {
ctx.update(src);
}
let digest = ctx.finish();
let out: Vec<String> = digest
.as_ref()
.iter()
.map(|byte| format!("{:02x}", byte))
.collect();
out.join("")
}