Fuzzy and URL Encoding Parameter

I want to encrypt a URL variable so that the user cannot see the information when it is transmitted. I found several scripts on the Internet, but none of them work. Most seem to be inclined toward using base-64. Can someone help me write a short script that will encode or encrypt and then reverse this on the next page? It does not have to be super secure, enough to mask the email address to the average user.

+3
source share
2 answers

If you are not concerned about security, you can simply use rot13 :

function rot13($string, $mode) {
    $s = fopen("php://memory", "rwb");
    stream_filter_append($s, "string.rot13", STREAM_FILTER_WRITE);
    fwrite($s, $string);
    rewind($s);
    return stream_get_contents($s);
}

var_dump(rot13("my@email.com", STREAM_FILTER_WRITE));
var_dump(rot13("zl@rznvy.pbz", STREAM_FILTER_READ));

will give:

string(12) "zl@rznvy.pbz"
string(12) "my@email.com"
+2

Source: https://habr.com/ru/post/1761824/


All Articles