php encryption functions md5 crypt base64_encode etc

  • 2020-05-16 06:34:45
  • OfStack

The irreversible encryption functions are: md5(), crypt()
md5() is used to calculate MD5 hash. The syntax is: string md5(string str);
crypt() encrypts the string with the DES module of UNIX's standard encryption. This is a one-way encryption function that cannot be decrypted. To match a string, place the first 2 characters of the encrypted string in the salt argument, and then match the encrypted string. The syntax is: string crypt(string str, string [salt]);
The reversible encryption is: base64_encode(), urlencode() corresponding decryption functions: base64_decode(), urldecode()

base64_encode() encodes the string as MIME BASE64. This encoding allows Chinese text or pictures to be transmitted over the network. The syntax is string base64_encode(string data); Its decryption function is: string base64_decode(string encoded_data); Will revert to the original
urlencode() encodes the string as URL. A space, for example, becomes a plus. The syntax is: string urlencode(string str);
Its decryption function is: string urldecode(string str); Will revert to the original

Look at the code:
 
<?php 
define("str"," The ink sword "); 
echo 'md5  The result after encryption is: '.md5(str).'<br>';//md5  encryption  
echo 'crypt The result after encryption is: '.crypt(str,str).'<br>';// crypt encryption  
$base64encode=base64_encode(str);// base64_encode()  encryption  
echo 'base64_encode The result after encryption is: '.$base64encode.'<br>'; 
echo 'base64_decode The result after decryption is: '.base64_decode($base64encode).'<br>'; //base64_decode() decryption  
$urlencode=urlencode(str); //urlencode()  encryption  
echo 'urlencode The result after encryption is: '.$urlencode.'<br>'; 
echo 'urldecode The result after decryption is: '.urldecode($urlencode).'<br>';//urldecode()  decryption  
?> 

The output result is:
md5 encrypted result is: the ea796af15c74e90faeba49576fa7984b
The result of crypt encryption is: ink ylCzgTtYXPs
The result of base64_encode encryption is: xKu9ow==
The result of base64_decode decryption is: ink sword
The result of urlencode encryption is: % C4% AB%BD%A3
The result of urldecode decryption is: ink sword

Related articles: