Working converting to konami id
This commit is contained in:
parent
9ac9ddb168
commit
b63b97ca53
@ -4,7 +4,6 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
medusa_macros = { path = "externals/medusa_macros"}
|
||||
async-trait = "0.1.82"
|
||||
byteorder = "1.5.0"
|
||||
cbc = "0.1.2"
|
||||
|
@ -10,6 +10,8 @@ mod utils;
|
||||
|
||||
use handlers::boot::get_services_handler::GetServicesHandler;
|
||||
use handlers::common::alive_pcb_tracker_handler::AlivePcbTrackerHandler;
|
||||
use handlers::common::card::inquire_card_managment_handler::InquireCardManagmentHandler;
|
||||
use handlers::common::get_facility_handler::GetFacilityHandler;
|
||||
use handlers::common::get_messages_handler::GetMessageHandler;
|
||||
use handlers::common::ota::list_package_handler::ListPackageHandler;
|
||||
use handlers::common::ota::progress_dl_status_handler::ProgressDLStatusHandler;
|
||||
@ -19,7 +21,6 @@ use rocket::fs::{relative, FileServer, NamedFile};
|
||||
use routes::ea::core_route::handle_query_request;
|
||||
use routes::ea::core_route::handle_slash_request;
|
||||
use routes::ea::e_amusement_route::handle_ea_query_request;
|
||||
//use handlers::common::get_facility_handler::handle_facility_get;
|
||||
|
||||
#[macro_use] extern crate lazy_static;
|
||||
#[macro_use] extern crate rocket;
|
||||
@ -37,6 +38,8 @@ fn register_handlers() -> Vec<Arc<dyn Handler>> {
|
||||
let put_pcb_event_handler = Arc::new(PutPcbEventHandler::new());
|
||||
let list_package_handler = Arc::new(ListPackageHandler::new());
|
||||
let progress_dl_status_handler = Arc::new(ProgressDLStatusHandler::new());
|
||||
let facility_get_handler = Arc::new(GetFacilityHandler::new());
|
||||
let inquire_card_managment_handler = Arc::new(InquireCardManagmentHandler::new());
|
||||
|
||||
let handlers: Vec<Arc<dyn Handler>> = vec![
|
||||
get_services_handler,
|
||||
@ -44,7 +47,9 @@ fn register_handlers() -> Vec<Arc<dyn Handler>> {
|
||||
get_messages_handler,
|
||||
put_pcb_event_handler,
|
||||
list_package_handler,
|
||||
progress_dl_status_handler
|
||||
progress_dl_status_handler,
|
||||
facility_get_handler,
|
||||
inquire_card_managment_handler
|
||||
];
|
||||
|
||||
handlers
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
use super::triple_des;
|
||||
|
||||
lazy_static! {
|
||||
@ -75,9 +74,14 @@ impl CardConvert {
|
||||
}
|
||||
|
||||
konami_id[14] = card_type as u8;
|
||||
konami_id[15] = Self::calculate_checksum(konami_id.clone());
|
||||
konami_id[15] = Self::calculate_checksum(&konami_id.clone());
|
||||
|
||||
Some(konami_id.iter().map(|&byte| ALPHABET[byte as usize]).collect())
|
||||
Some(
|
||||
konami_id
|
||||
.iter()
|
||||
.map(|&byte| ALPHABET[byte as usize])
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
fn generate_encryption_key() -> Vec<u8> {
|
||||
@ -108,21 +112,22 @@ impl CardConvert {
|
||||
result
|
||||
}
|
||||
|
||||
fn calculate_checksum(konami_id: Vec<u8>) -> u8 {
|
||||
let mut checksum: u8 = 0;
|
||||
fn calculate_checksum(data: &[u8]) -> u8 {
|
||||
let mut checksum: u32 = 0;
|
||||
|
||||
for i in 0..15 {
|
||||
if i >= konami_id.len() {
|
||||
if i >= data.len() {
|
||||
break;
|
||||
}
|
||||
|
||||
checksum = checksum.wrapping_add(konami_id[i] * ((i % 3) + 1) as u8);
|
||||
checksum += data[i] as u32 * ((i % 3) + 1) as u32;
|
||||
}
|
||||
|
||||
// Reduce the checksum to fit within 5 bits
|
||||
while checksum > 31 {
|
||||
checksum = (checksum >> 5) + (checksum & 31);
|
||||
}
|
||||
|
||||
// Return the checksum as a u8
|
||||
checksum as u8
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user