Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
duyuefeng0708
GitHub Repository: duyuefeng0708/Cryptography-From-First-Principle
Path: blob/main/shared/src/utils.rs
483 views
unlisted
1
/// Display a value in binary with a given bit width.
2
pub fn to_binary_string(val: u64, width: usize) -> String {
3
format!("{:0>width$b}", val, width = width)
4
}
5
6
/// Simple assertion helper with descriptive message for exercises.
7
pub fn check(condition: bool, msg: &str) {
8
assert!(condition, "Exercise check failed: {}", msg);
9
}
10
11