PHP | Imagick encipherImage() Function

The Imagick::encipherImage() function is an inbuilt function in PHP which is used to convert plain pixels image into enciphered pixels. This function simply converts the pixels to enciphered pixels and then the image can be readable only if decipher the image with the same string with which it was enciphered.

Syntax:

bool Imagick::encipherImage( $passphrase )

Parameters: This function accepts single parameter $passphrase which holds the passphrase value.



Return Value: It returns True on success or False on failure.

Below program illustrates the Imagick::encipherImage() function in PHP:

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Creating new Imagick object
$image = new Imagick(
  
// Creating the passphrase
$passphrase = "GeeksforGeeks";
  
// Calling the function
$image->encipherImage($passphrase);
  
// $image is now enciphered with string
// "GeeksforGeeks"
// $image can only be made readable by 
// decipherImage() method
// with the same passphrase as parameter
  
header("Content-Type: image/jpg"); 
  
// Showing the deciphered image which is
// same as our sampleimage.jpeg
echo $image;
  
?>

chevron_right


Output:
Deciphered image if the passphrase is incorrect :

Reference: https://php.net/manual/en/imagick.encipherimage.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : AllBoutStudies