myph-v2.git


myph-v2

~ rust shellcode loader with evasive capabilities
git clone https://github.com/djnnvx/myph-v2.git
log | files | refs | archive | README

validation.rs (1039B)

      1 /// Returns the is_valid_utf8 function implementation as a string
      2 pub fn internals_is_valid_utf8() -> &'static str {
      3     r#"/// Validates that a byte slice is valid UTF-8
      4 ///
      5 /// Returns `true` if the bytes form valid UTF-8, `false` otherwise.
      6 pub fn is_valid_utf8(data: &[u8]) -> bool {
      7     std::str::from_utf8(data).is_ok()
      8 }"#
      9 }
     10 
     11 /// Returns the compute_checksum function implementation as a string
     12 pub fn internals_compute_checksum() -> &'static str {
     13     r#"/// Computes a simple checksum for data verification
     14 ///
     15 /// Returns the sum of all bytes modulo 256.
     16 pub fn compute_checksum(data: &[u8]) -> u8 {
     17     data.iter().fold(0u8, |acc, &b| acc.wrapping_add(b))
     18 }"#
     19 }
     20 
     21 /// Returns the validate_checksum function implementation as a string
     22 pub fn internals_validate_checksum() -> &'static str {
     23     r#"/// Validates a checksum against data
     24 ///
     25 /// Returns `true` if the checksum matches the computed checksum.
     26 pub fn validate_checksum(data: &[u8], expected_checksum: u8) -> bool {
     27     compute_checksum(data) == expected_checksum
     28 }"#
     29 }