Skip to content

Instantly share code, notes, and snippets.

@symisc
Created April 3, 2021 00:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symisc/c164501a2c59948430d1e06859f2ec3a to your computer and use it in GitHub Desktop.
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
<?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