#random #md5 #utility #parser

e9571_lib1

A Rust crate providing utilities for time formatting, HTTP requests, string parsing, and more

3 releases

Uses new Rust 2024

0.1.2 Aug 19, 2025
0.1.1 Aug 11, 2025
0.1.0 Aug 9, 2025

#1140 in Network programming

Download history 216/week @ 2025-08-06 120/week @ 2025-08-13 72/week @ 2025-08-20 28/week @ 2025-08-27 44/week @ 2025-09-03 20/week @ 2025-09-10 14/week @ 2025-09-17 26/week @ 2025-09-24 39/week @ 2025-10-01 4/week @ 2025-10-08 25/week @ 2025-10-15 18/week @ 2025-10-22

89 downloads per month
Used in 4 crates

MIT license

16KB
181 lines

e9571_lib1 Usage Examples

This document demonstrates the usage of the e9571_lib1 module in a Rust program, tailored for casino-related operations such as generating user IDs, making HTTP requests, parsing data, and handling system information.

Source Code Example

Below is a Rust program showcasing various functions from the e9571_lib1 module. The code includes examples for random ID generation, HTTP requests, regex processing, and more, with error handling and casino-relevant use cases.

use e9571_lib1::e9571_lib1::*;
use std::collections::HashMap;

fn main() {
    // Example 1: High_Rand_User
    println!("=== High_Rand_User ===");
    println!("User ID: {}", high_rand_user("user_"));

    // Example 2: HTTP GET
    println!("\n=== HTTP GET ===");
    match get_http("https://httpbin.org/get") {
        Ok(body) => println!("HTTP GET body length: {}", body.len()),
        Err(e) => println!("HTTP GET error: {}", e),
    }

    // Example 3: HTTP GET with Timeout
    println!("\n=== HTTP GET Wait ===");
    match get_http_wait("https://httpbin.org/get", 10, 1) {
        Ok(body) => println!("HTTP GET (wait) body length: {}", body.len()),
        Err(e) => println!("HTTP GET (wait) error: {}", e),
    }

    // Example 4: Parse Numbers
    println!("\n=== Parse Numbers ===");
    println!("Parse int: {}", parse_int("123"));
    println!("Parse int8: {}", parse_int8("123"));
    println!("Parse uint8: {}", parse_uint8("123"));
    println!("Parse int64: {}", parse_int64("123456789"));
    println!("Parse uint64: {}", parse_uint64("123456789"));
    println!("Parse float: {}", parse_float("123.456"));

    // Example 5: Regex Functions
    println!("\n=== Regex Functions ===");
    let source = "test123 abc456 def789";
    let numbers = get_data_preg_list(r"\d+", source);
    println!("Preg list (numbers): {:?}", numbers);
    println!("Preg str (contains '456'): {}", get_data_preg_str(numbers.clone(), "456"));
    println!("Create number: {}", create_number(source));
    println!("Preg address: {}", get_data_preg_address(source));
    println!("Preg address letter: {}", get_data_preg_address_letter(source));

    // Example 6: Preg Search
    println!("\n=== Preg Search ===");
    let html = "<tr>Confirmations: 123</tr>";
    println!("Preg search: {}", get_data_preg_search_str(html, r"<tr>[.\s\S]*?</tr>", "Confirmations", 10));

    // Example 7: Map Sorting
    println!("\n=== Map Sorting ===");
    let mut map = HashMap::new();
    map.insert("b".to_string(), "2".to_string());
    map.insert("a".to_string(), "1".to_string());
    println!("Sorted keys: {:?}", taxis_map(map));

    // Example 8: Error Handling
    println!("\n=== Error Handling ===");
    let err = sprintf_err_write("test error");
    println!("Error: {}", sprintf_err_msg(Some(&*err)));

    // Example 9: MD5
    println!("\n=== MD5 ===");
    println!("MD5 (hello): {}", default_encode_md5("hello"));
    println!("MD5 (abcdefghijklmnopqrstuvwxyz): {}", default_encode_md5("abcdefghijklmnopqrstuvwxyz"));

    // Example 10: Word Split
    println!("\n=== Word Split ===");
    println!("Split: {:?}", word_split("a,b,c", ","));

    // Example 11: SQL Filtrate
    println!("\n=== SQL Filtrate ===");
    println!("SQL filtrate: {}", sql_filtrate("test' # --"));
    println!("SQL filtrate str: {}", sql_filtrate_str("test123!@#"));

    // Example 12: In Array
    println!("\n=== In Array ===");
    let arr = vec!["a".to_string(), "b".to_string()];
    println!("In array (string): {}", in_array(&arr, "a"));
    let int_arr = vec![1, 2, 3];
    println!("In array (int): {}", in_array_int(&int_arr, 2));
    let int64_arr = vec![123456789];
    println!("In array (int64): {}", in_array_int64(&int64_arr, 123456789));
    let float_arr = vec![1.23, 4.56];
    println!("In array (float): {}", in_array_float(&float_arr, 1.23));

    // Example 13: Conversion Num
    println!("\n=== Conversion Num ===");
    println!("Format number: {}", conversion_num(123.456789, 2));

    // Example 14: System Info
    println!("\n=== System Info ===");
    println!("Local IP: {}", create_ip());
    println!("Args: {:?}", create_args());
    println!("Exe name: {}", create_exe_name());
    match create_path_os() {
        Ok(path) => println!("Exe path: {}", path),
        Err(e) => println!("Exe path error: {}", e),
    }
}

Explanation of Functions

The e9571_lib1 module provides a versatile set of utility functions for casino applications, including random ID generation, HTTP requests, data parsing, regex processing, and system information retrieval.

  1. high_rand_user:

    • Generates a high-precision random user ID with a prefix (e.g., user_).
    • Use Case: Creating unique user IDs for casino accounts.
  2. get_http:

    • Performs an HTTP GET request and returns the response body.
    • Use Case: Fetching external game data or odds from an API.
  3. get_http_wait:

    • Performs an HTTP GET request with a timeout and retry mechanism.
    • Use Case: Reliable API calls for real-time betting updates.
  4. parse_int, parse_int8, parse_uint8, parse_int64, parse_uint64, parse_float:

    • Converts string inputs to respective numeric types.
    • Use Case: Parsing bet amounts or transaction values from user input.
  5. get_data_preg_list, get_data_preg_str, create_number, get_data_preg_address, get_data_preg_address_letter:

    • Regex-based functions for extracting numbers, checking patterns, or parsing addresses.
    • Use Case: Validating blockchain addresses or extracting bet IDs from logs.
  6. get_data_preg_search_str:

    • Searches for a pattern in HTML/text and extracts a specific value.
    • Use Case: Parsing transaction confirmations from external sources.
  7. taxis_map:

    • Sorts a HashMap by keys and returns a sorted vector.
    • Use Case: Organizing user data or bet records alphabetically.
  8. sprintf_err_write, sprintf_err_msg:

    • Handles error creation and message formatting.
    • Use Case: Logging errors during betting or transaction processing.
  9. default_encode_md5:

    • Computes the MD5 hash of a string.
    • Use Case: Generating secure identifiers for transactions or bets.
  10. word_split:

    • Splits a string into a vector based on a delimiter.
    • Use Case: Parsing comma-separated bet options or user inputs.
  11. sql_filtrate, sql_filtrate_str:

    • Sanitizes strings to prevent SQL injection.
    • Use Case: Securing database queries for user data or bets.
  12. in_array, in_array_int, in_array_int64, in_array_float:

    • Checks if a value exists in an array of strings, integers, or floats.
    • Use Case: Validating bet types or user IDs in predefined lists.
  13. conversion_num:

    • Formats a number to a specified number of decimal places.
    • Use Case: Displaying formatted bet amounts or payouts.
  14. create_ip, create_args, create_exe_name, create_path_os:

    • Retrieves system information like IP address, command-line arguments, or executable path.
    • Use Case: Logging system details for debugging or audit trails.

Casino Scenario Usage

These functions are ideal for casino applications, such as:

  • User Management: Generating unique user IDs (high_rand_user) or validating inputs (in_array, parse_*).
  • API Integration: Fetching real-time odds or game data (get_http, get_http_wait).
  • Data Processing: Parsing logs or blockchain addresses (get_data_preg_*, create_number).
  • Security: Sanitizing inputs (sql_filtrate) and hashing data (default_encode_md5).
  • System Monitoring: Logging system details for audit or debugging (create_ip, create_path_os).

Example Output

The output depends on the implementation of e9571_lib1 and system state. An example output might look like:

=== High_Rand_User ===
User ID: user_123456789

=== HTTP GET ===
HTTP GET body length: 256

=== HTTP GET Wait ===
HTTP GET (wait) body length: 256

=== Parse Numbers ===
Parse int: 123
Parse int8: 123
Parse uint8: 123
Parse int64: 123456789
Parse uint64: 123456789
Parse float: 123.456

=== Regex Functions ===
Preg list (numbers): ["123", "456", "789"]
Preg str (contains '456'): true
Create number: 123456789
Preg address: <empty or matched address>
Preg address letter: <empty or matched letters>

=== Preg Search ===
Preg search: 123

=== Map Sorting ===
Sorted keys: [("a", "1"), ("b", "2")]

=== Error Handling ===
Error: test error

=== MD5 ===
MD5 (hello): 5d41402abc4b2a76b9719d911017c592
MD5 (abcdefghijklmnopqrstuvwxyz): c3fcd3d76192e4007dfb496cca67e13b

=== Word Split ===
Split: ["a", "b", "c"]

=== SQL Filtrate ===
SQL filtrate: test
SQL filtrate str: test123

=== In Array ===
In array (string): true
In array (int): true
In array (int64): true
In array (float): true

=== Conversion Num ===
Format number: 123.46

=== System Info ===
Local IP: 192.168.1.100
Args: ["./program"]
Exe name: program
Exe path: /path/to/program

Notes

  • Module Dependency: The e9571_lib1 module is assumed to be available and correctly implemented.
  • Error Handling: The code uses Result for HTTP requests and system operations to handle errors robustly.
  • Casino Context: Functions like high_rand_user, default_encode_md5, and sql_filtrate are critical for secure user and transaction management.
  • GitHub Rendering: This Markdown uses Rust syntax highlighting, clear headings, and structured explanations for optimal display.
  • Security: Ensure proper validation for inputs (e.g., regex patterns, HTTP URLs) and secure handling of system information in production.

Dependencies

~8–24MB
~291K SLoC