mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
86b3ac5108
Use --lock-write=lock.json or --lock-check=lock.json on the command line.
20 lines
450 B
Rust
20 lines
450 B
Rust
use ring;
|
|
use std::fmt::Write;
|
|
|
|
pub fn gen(v: Vec<&[u8]>) -> String {
|
|
let mut ctx = ring::digest::Context::new(&ring::digest::SHA256);
|
|
for src in v.iter() {
|
|
ctx.update(src);
|
|
}
|
|
let digest = ctx.finish();
|
|
let mut out = String::new();
|
|
// TODO There must be a better way to do this...
|
|
for byte in digest.as_ref() {
|
|
write!(&mut out, "{:02x}", byte).unwrap();
|
|
}
|
|
out
|
|
}
|
|
|
|
pub fn gen2(s: &str) -> String {
|
|
gen(vec![s.as_bytes()])
|
|
}
|