public
Last active

BSCrypt is encryption that isn't actually encryption, just a way to hide stuff from users. Why? I don't know. Encrypt sensitive data and save it in a cookie or something.

  • Download Gist
BSCrypt.class.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php
 
//BSCrypt version 1.0
//Scott Kaye
//Encryption that isn't actually encryption, just a way to hide stuff from users
//Made to be as complicatedly stupid and useless as possible
 
//"Class"
class BSCrypt {
private static $entropy = 1;
 
public static function setEntropy($entropy) {
if(is_int($entropy)) {
self::$entropy = $entropy;
}
}
 
private static function entropinize($str, $encryptOrDecrypt) {
$n = array();
foreach(array_filter(preg_split('//',$str)) as $c) {
$encryptOrDecrypt ? array_push($n, chr(ord($c) + self::$entropy)) : array_push($n, chr(ord($c) - self::$entropy));
}
return join('',$n);
}
 
public static function encrypt($str) {
return strrev(str_rot13(base64_encode(self::entropinize($str,1))));
}
 
public static function decrypt($str) {
return self::entropinize(base64_decode(str_rot13(strrev($str))),0);
}
}
 
//Implementation
BSCrypt::setEntropy(4); //Guaranteed to be random
$in = BSCrypt::encrypt("This is some random crap");
echo $in;
 
echo "<br>";
 
$out = BSCrypt::decrypt($in);
echo $out;
 
//Designed and built with all the love in the world that I could spare in 5 minutes
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.