Share a freshly written PHP encryption and decryption function

Source: Internet
Author: User

Base64 encryption of different or string encryption methods

Encryption

function encode ($str, $key) {    $res = Base64_encode ($STR);    $code = $res ^ $key;    return $code;}

Decrypt

function decode ($STR, $key) {    return Base64_decode ($str ^ $key);}

Complete code example:

$str = ' 111021 '; $key = ' appyjj-phone-lazy '; function encode ($str, $key) {    $res = Base64_encode ($STR);    $code = $res ^ $key;    return $code;} $str = Encode ($str, $key);p Rint_r ($STR), echo "
    • The whole procedure is very simple ~ according to logical thinking should be difficult to crack, in the case of others do not know your secret key;

    • If it doesn't feel safe. So I'm going to make a point here; we recommend that you continue to use the shift operation during the encryption and decryption process.

When encrypting, $a = $str >> 4;//decryption is the opposite of $ A = $str << 4;

Ok!~, the blogger continues to work! ~~

Base64 encryption of different or string encryption methods

Encryption

function encode ($str, $key) {    $res = Base64_encode ($STR);    $code = $res ^ $key;    return $code;}

Decrypt

function decode ($STR, $key) {    return Base64_decode ($str ^ $key);}

Complete code example:

$str = ' 111021 '; $key = ' appyjj-phone-lazy '; function encode ($str, $key) {    $res = Base64_encode ($STR);    $code = $res ^ $key;    return $code;} $str = Encode ($str, $key);p Rint_r ($STR), echo "
    • The whole procedure is very simple ~ according to logical thinking should be difficult to crack, in the case of others do not know your secret key;

    • If it doesn't feel safe. So I'm going to make a point here; we recommend that you continue to use the shift operation during the encryption and decryption process.

When encrypting, $a = $str >> 4;//decryption is the opposite of $ A = $str << 4;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.