In what scenarios would using base64_encode and a simple encryption method like rotxx be appropriate in PHP?

Using base64_encode and a simple encryption method like rotxx can be appropriate when you need to obfuscate sensitive data before storing it in a database or transmitting it over a network. These methods provide a basic level of security by encoding the data in a way that is not easily readable to the naked eye. However, it's important to note that these methods are not secure enough for highly sensitive information and should not be used as a replacement for proper encryption techniques.

// Encrypting sensitive data using base64_encode and a simple rotation cipher (rotxx)
function encryptData($data, $rotation) {
    $encryptedData = str_rot13(base64_encode($data));
    return str_rot($encryptedData, $rotation);
}

// Decrypting encrypted data
function decryptData($encryptedData, $rotation) {
    $decryptedData = str_rot($encryptedData, -$rotation);
    return base64_decode(str_rot13($decryptedData));
}

// Example usage
$data = "Sensitive information";
$rotation = 13;

$encryptedData = encryptData($data, $rotation);
echo "Encrypted data: " . $encryptedData . "\n";

$decryptedData = decryptData($encryptedData, $rotation);
echo "Decrypted data: " . $decryptedData . "\n";