PHP short encrypt

user1123379 picture user1123379 · Feb 27, 2012 · Viewed 11.5k times · Source

I'm using this code:

$url = "http://www.webtoolkit.info/javascript-base64.html";
print base64_encode($url);

But the result is very long: "aHR0cDovL3d3dy53ZWJ0b29sa2l0LmluZm8vamF2YXNjcmlwdC1iYXNlNjQuaHRtbA=="

There is a way to transform long string to short encryption and to be able to transform?

for example:

new_encrypt("http://www.webtoolkit.info/javascript-base64.html")
Result: "431ASDFafk2"

Answer

GordonM picture GordonM · Feb 27, 2012

encoding is not encrypting. If you're depending on this for security then you're in for a very nasty shock in the future.

Base 64 encoding is intended for converting data that's 8 bits wide into a format that can be sent over a communications channel that uses 6 or 7 bits without loss of data. As 6 bits is less than 8 bits the encoded string is obviously going to be longer than the original.