Last active
September 22, 2021 02:53
-
-
Save kavanmevada/22e05ff2435f2af6510513b3af3a21a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
#![feature(core_intrinsics)] | |
// extern crate base64; // 0.13.0 | |
extern crate sha2; // 0.9.5 | |
extern crate test; | |
mod d_const; | |
mod tmp2; | |
use std::{ | |
ffi::CString, | |
fmt::Binary, | |
io::Read, | |
ops::{BitAnd, Shl, Shr, Sub}, | |
rc::Rc, | |
str::Bytes, | |
}; | |
use crate::base64::{chromium_base64_decode_len, chromium_base64_encode_len}; | |
use bluetooth_device_name::bluetooth_device_name; | |
use libc::strlen; | |
use sha2::{digest::generic_array::typenum::Integer, Digest, Sha256, Sha512}; | |
macro_rules! LAST { | |
($k:expr,$n:expr) => { | |
($k) & ((1 << ($n)) - 1) | |
}; | |
} | |
macro_rules! MID { | |
($k:expr,$m:expr,$n:expr) => { | |
LAST!(($k) >> ($m), (($n) - ($m))) | |
}; | |
} | |
mod base64; | |
mod bluetooth_device_name; | |
#[derive(Debug)] | |
pub enum Error { | |
DecodeError, | |
DecodeEmpty, | |
} | |
fn main() -> Result<(), Error> { | |
// let kVersion = Version::kV1; | |
// let kPcp = Pcp::kP2pCluster; | |
// let kEndPointID = "AB12"; | |
// let kServiceIDHashBytes = std::str::from_utf8(&[0x0a, 0x0b, 0x0c]); | |
// let kEndPointName1 = "RAWK + ROWL!"; | |
// let kEndPointName2 = "How much wood can a woodchuck chuck if a wood chuck would chuck wood?"; | |
// let kWebRtcState = WebRtcState::kConnectable; | |
// let kFastAdvertisementEndpointName = "Fast Advertise"; | |
// let kBluetoothMacAddress = "00:00:E6:88:64:13"; | |
// TW90byBQb3dlcg== | |
let str = "Moto Power"; | |
if let Some(encode) = crate::base64::encode("Moto Power") { | |
dbg!(&encode); | |
} | |
//TW90byBQb3dlcg== | |
// let bluetooth_device_name_string = | |
// "I0RJT0v8n14AAAAAAAAAJAIHH9Hn7D95JAAvuiKcukWlEkthdmFuJ3MgUGl4ZWwgMiBYTA"; | |
// let bluetooth_device_name_string = "SLAAUMHVe6xCmmUGl4ZWwgMmHhrVBNUBDwAKk"; | |
// bluetooth_device_name::bluetooth_device_name(bluetooth_device_name_string)?; | |
// 08:D4:6A:41:BC:F9 | |
// I0RJT0v8n14 | |
// 23 44 49 4f 4b fc 9f 5e | |
// 00100011 01000100 01001001 01001111 01001011 11111100 10011111 01011110 | |
// | |
// version_and_pcp_byte -> 00100011 -> 001,00011 -> 1,3 -> v1,pcpv3 | |
// | |
// 31 39 32 | |
// 192:168:1:66 | |
// 0a187b089f6aff87d9168841163edc6f1a737cc8e73b10998777e60778541d7f | |
let data = [ | |
0x23 /* v1, pcpv3 */, | |
0x44, 0x49, 0x4f, 0x4b, /* endpoint_id */ | |
0xfc, 0x9f, 0x5e, /* service_id_hash */ | |
0x00, /* web_rtc_state */ | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* reserved_length */ | |
0x24, /* expected_endpoint_info_length = 36 */ | |
0x02 /* 002 */, | |
0x07 /* 007 */, | |
0x1f /* 031 */, | |
0xd1 /* 209 */, | |
0xe7 /* 231 */, | |
0xec /* 236 */, | |
0x3f /* 063 */, | |
0x79 /* 121 */, | |
0x24 /* 036 */, | |
0x00 /* 000 */, | |
0x2f /* 047 */, | |
0xba /* 186 */, | |
0x22 /* 034 */, | |
0x9c /* 156 */, | |
0xba /* 186 */, | |
0x45 /* 069 */, | |
0xa5 /* 156 */, | |
0x12 /* 18 (Decimal) = length_of_endpoint_name */ , | |
0x4b /* K */ , | |
0x61 /* a */ , | |
0x76 /* v */ , | |
0x61 /* a */ , | |
0x6e /* n */ , | |
0x27 /* ' */ , | |
0x73 /* s */ , | |
0x20 /* space */ , | |
0x50 /* P */ , | |
0x69 /* i */ , | |
0x78 /* x */ , | |
0x65 /* e */, | |
0x6c /* l */, | |
0x20 /* space */, | |
0x32 /* 2 */, | |
0x20 /* space */, | |
0x58 /* X */, | |
0x4c /* L */, | |
]; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment