Created
April 3, 2021 00:45
-
-
Save symisc/c164501a2c59948430d1e06859f2ec3a to your computer and use it in GitHub Desktop.
Encrypt an Image to Enciphered Pixels using the PixLab API - https://pixlab.io/cmd?id=encrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github | |
* https://github.com/symisc/pixlab-php | |
*/ | |
require_once "pixlab.php"; | |
# Converts plain pixels of a given image to enciphered pixels. The image is not readable until it has been deciphered using decrypt. | |
# https://pixlab.io/cmd?id=encrypt && https://pixlab.io/cmd?id=decrypt | |
# Target image to enrypt | |
$img = 'https://pixlab.io/images/bencrypt.png'; | |
# Password used for decryption | |
$pwd = 'superpass'; | |
$pix = new Pixlab('PIXLAB_API_KEY'); # PixLab API Key - Get yours from https://pixlab.io/dashboard | |
/* Grab the face landmarks first */ | |
if( !$pix->get('encrypt',[ | |
'img' => $img, | |
'pwd' => $pwd | |
]) ){ | |
echo $pix->get_error_message()."\n"; | |
die; | |
} | |
echo "Link to the encrypted picture: ".$pix->json->ssl_link."\n"; | |
# Call https://api.pixlab.io/decrypt with your passphrase to make it readable again |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment