Created
October 19, 2016 21:12
-
-
Save joequery/5fa61c0ed58aa7c412a1aebc0f9828a9 to your computer and use it in GitHub Desktop.
sombra encrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function str_rot($s, $n = 13) { | |
static $letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$n = (int)$n % 26; | |
if (!$n) return $s; | |
if ($n == 13) return str_rot13($s); | |
for ($i = 0, $l = strlen($s); $i < $l; $i++) { | |
$c = $s[$i]; | |
if ($c >= 'a' && $c <= 'z') { | |
$s[$i] = $letters[(ord($c) - 71 + $n) % 26]; | |
} else if ($c >= 'A' && $c <= 'Z') { | |
$s[$i] = $letters[(ord($c) - 39 + $n) % 26 + 26]; | |
} | |
} | |
return $s; | |
} | |
function encrypt($password) { | |
$passArray = str_split($password); | |
$encrypted = array(); | |
foreach($passArray as $char) { | |
$salt = count($encrypted); | |
$char = base64_encode(dechex(ord(str_rot($char,($salt+3)))*3)); | |
if($salt % 2 == 0) $char = strrev($char); | |
array_push($encrypted, $char); | |
} | |
$encrypted = implode(":", $encrypted); | |
$encrypted = str_replace("=", "?", $encrypted); | |
return $encrypted; | |
} | |
$dudepw = "Xy@4+Bkuqd<53uJ"; | |
$x = encrypt($dudepw); | |
echo $x; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: