pub fn base64_encode(input: &str) -> StringExpand description
Encodes text to Base64.
Converts input text to Base64 encoding using the standard RFC 4648 alphabet. This is a lossless encoding that increases the string length by approximately 33% and is commonly used for transmitting binary data or obfuscating payloads.
§Use Cases
- Red Team: Obfuscate command payloads to evade detection
- Data Transmission: Safely encode binary data in text formats
- Blue Team: Test if security systems properly decode Base64
- API Testing: Encode credentials or tokens
§Examples
use redstr::base64_encode;
assert_eq!(base64_encode("hello"), "aGVsbG8=");
assert_eq!(base64_encode("test"), "dGVzdA==");
// Obfuscate shell commands
let cmd = base64_encode("rm -rf /tmp/*");
assert_eq!(cmd, "cm0gLXJmIC90bXAvKg==");
// Encode credentials
let auth = base64_encode("username:password");
// Use in Authorization: Basic header