#checksum #protocols #random #validate #true #time-delta #rcp

rc_protocol

Rust语言的随机校验协议实现

1个稳定版本

1.0.0 2022年8月5日

#806 in 认证

MIT 协议

12KB
143

rcp-rs

Rust中对RCP的实现

用法

use std::collections::HashMap;
use rc_protocol::RCPConfig;

// Config is used to create a checksum as well as validate a checksum
let config = RCPConfig {
  shared_secret: "Shared Secret Key".to_string(),
  use_time_component: true,
  time_delta: 5,
};

let mut m = HashMap::new();
m.insert("key1", "value1");
m.insert("key2", "value2");

// Get the checksum for a given dictionary
let checksum = config.get_checksum(&m, "TestSalt"); 

// Validate a given checksum
if !config.validate_checksum(&m, "TestSalt", &checksum) {
     println!("Checksum was incorrect");
}

依赖

~1.5MB
~28K SLoC