Javatpoint Logo
Javatpoint Logo

Two-way Encryption

By using this concept, we can encode and decode the data. In simple terms, two-way encryption means there is both encrypt and decrypt function present. In PHP, two-way encryption is accomplished through the following function.

  1. base64_encode()
  2. base64_decode()

1. base64_encode()

This function is used to encode the given data with base64. This function was introduced in PHP 4.0.

Syntax

Parameters

Parameter Description Is compulsory
data The data to be encoded. compulsory

Returns:

The base64_encode() function returns the encoded data as string.

Example 1

Output:

Two-way Encryption

Example 2

Output:

Two-way Encryption

2. base64_decode():

The base64_decode() function is used to decode a base64 encoded data. This function was introduced in PHP 4.0.

Syntax

Parameters

Parameter Description Is compulsory
data The encoded data. compulsory
strict If the strict parameter is set to TRUE, then the base64_decode() function will return FALSE if the input contains character from outside the base64 alphabet. Optional

Returns:

The base64_decode() function returns the decoded data or false on failure. The returned data may be binary.

Example 1

Output:

Two-way Encryption

Example 2

Output:

Two-way Encryption
Next TopicPHP Tutorial




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA