Improve md5 and sha256 code (#3841)

* Refactor Hash code to simplify md5 and sha256 implementations

Md5 and Sha256 (and other future digests) require less boilerplate code
now. Error reporting includues the name of the hash again.

* Add missing hash sha256 test
This commit is contained in:
Peter Cunderlik
2021-07-29 16:22:16 +01:00
committed by GitHub
parent 7f7af2bbaa
commit 9696e4d315
5 changed files with 100 additions and 74 deletions

View File

@ -96,3 +96,19 @@ fn md5_works_with_file() {
assert_eq!(actual.out, "4de97601d232c427977ef11db396c951");
}
#[test]
fn sha256_works_with_file() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.db | hash sha256
"#
)
);
assert_eq!(
actual.out,
"2f5050e7eea415c1f3d80b5d93355efd15043ec9157a2bb167a9e73f2ae651f2"
);
}