Common cryptographic algorithms for PHP

Source: Internet
Author: User
Tags alphanumeric characters

One: one-way encryption algorithm

1. MD5 ($STR, BOOL): Returns 32 bits by default, and returns 16-bit binary characters for true;

2, Crypt ($strl, $salt): $salt for interference string, placed in front of the ciphertext, there are many formats;

3. SHA1 ($STR, BOOL): Returns 40 bits by default, returns 20-bit source format characters for true;

Two: Two-way encryption algorithm

1, UrlEncode ();

2, Rawurlencode ();

3, Base64_encode (): transcoding pictures, etc.,

where UrlEncode () and Rawurlencode () are analyzed:

One: The difference is:

UrlEncode () Turns the space to the ' + ' sign, and Rawurlencode () turns the space into%20, which is the only difference.

Two: The same point:

All non-alphanumeric characters except-_ are encoded and converted to% plus two-bit hexadecimal characters.

One-way hash algorithm, symmetric algorithm, asymmetric algorithm:

One-way hashing algorithm: Converts characters of different lengths into strings of the same length;

Symmetric algorithm: Encryption and decoding of the same key, encryption/decryption fast;

Asymmetric algorithm: Encryption uses the public key known to everyone, while decoding can only use the private key you know.

Common cryptographic algorithms for PHP

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.