Skip to content

Instantly share code, notes, and snippets.

View gugglegum's full-sized avatar

Paul Melekhov gugglegum

View GitHub Profile
@gugglegum
gugglegum / url_hide_password.php
Created March 18, 2019 05:47
Replace password in URL to "******" if present (prepare secret URL for publishing in logs, reports, etc.)
<?php
$username = 'John';
$password = '%3q~7:rN@p';
$url = 'http://' . urlencode($username) . ':' . urlencode($password) . '@www.example.com/path/to/file.txt';
echo "Original URL: {$url}\n";
echo "Hidden password URL: " . hidePasswordFromUrl($url) . "\n";