diff --git a/Cargo.lock b/Cargo.lock
index 898b3898162..3991aedb268 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2494,6 +2494,7 @@ version = "0.0.26"
dependencies = [
"clap",
"hex",
+ "regex",
"uucore",
]
diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml
index f6a5a138a83..dcd5b56b1fd 100644
--- a/src/uu/cksum/Cargo.toml
+++ b/src/uu/cksum/Cargo.toml
@@ -18,6 +18,7 @@ path = "src/cksum.rs"
clap = { workspace = true }
uucore = { workspace = true, features = ["encoding", "sum"] }
hex = { workspace = true }
+regex = { workspace = true }
[[bin]]
name = "cksum"
diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs
index 2397cca7820..746b22b104c 100644
--- a/src/uu/cksum/src/cksum.rs
+++ b/src/uu/cksum/src/cksum.rs
@@ -5,13 +5,18 @@
// spell-checker:ignore (ToDO) fname, algo
use clap::{crate_version, value_parser, Arg, ArgAction, Command};
+use regex::Regex;
+use std::cmp::Ordering;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Display;
use std::fs::File;
+use std::io::BufRead;
use std::io::{self, stdin, stdout, BufReader, Read, Write};
use std::iter;
use std::path::Path;
+use uucore::error::set_exit_code;
+use uucore::show_warning_caps;
use uucore::{
encoding,
error::{FromIo, UError, UResult, USimpleError},
@@ -212,7 +217,8 @@ where
OutputFormat::Hexadecimal => sum_hex,
OutputFormat::Base64 => match options.algo_name {
ALGORITHM_OPTIONS_CRC | ALGORITHM_OPTIONS_SYSV | ALGORITHM_OPTIONS_BSD => sum_hex,
- _ => encoding::encode(encoding::Format::Base64, &hex::decode(sum_hex).unwrap()).unwrap(),
+ _ => encoding::encode(encoding::Format::Base64, &hex::decode(sum_hex).unwrap())
+ .unwrap(),
},
};
// The BSD checksum output is 5 digit integer
@@ -310,6 +316,7 @@ mod options {
pub const RAW: &str = "raw";
pub const BASE64: &str = "base64";
pub const CHECK: &str = "check";
+ pub const STRICT: &str = "strict";
pub const TEXT: &str = "text";
pub const BINARY: &str = "binary";
}
@@ -357,12 +364,8 @@ fn calculate_length(algo_name: &str, length: usize) -> UResult