GCS Learn
Data Protection with Imcrypt
Author - GIGOCYBERSPACE
Republished - 22 November 2024
Imcrypt is a CLI tool written in JavaScript used to re-shape images by using the key with an arbitrary computer algorithm
Imcrypt works by you putting in a key from a file and through JavaScript, its generate an image that can not be understood. An image generated by imcrypt looks like this:
In this course, you'll learn how to encrypt and decrypt those images with the key. Which helps in more privacy control.
Install Imcrypt
We can use Imcrypt in two ways:
- By running it virtually: Using npx- A JavaScript library(We don't not actually installing it).
- Using npm- Also a JavaScript library (We're actually installing it).
For the purpose of this course we will run it virtually to save time.
Pick your image and set your key
Now you have to pick your files. We in this course, will use an image called bike.png and our ke will be stored in the file key.txt. You might be wondering why we're using a PNG file why couldn't we use a better image format like JPG. Well, the reason is because, when files are encrypted and decrypted back in JPG with Imcrypt, some pixels are loss and it is not the best options. So that's why we used a PNG format. Anyway, this is the image we will use:
So to encrypt we type this command
root@kali : ~ # imcrypt -e <iamge_to_encrypt> -k <location_to_key_file> -i <output_of_iamge>
imcrypt v1.0.1 by theninza
An image encryption node-js cli
✔ Image read successfully
✔ Output image file name is valid
✔ Output key file name is valid
✔ Image data read successfully
✔ Key generated successfully
✔ Image encrypted successfully
✔ Image saved successfully
✔ Key saved successfully
✔ Image encrypted successfully Image encrypted successfully:
Encrypted Image: bike_e.png
Key: bike_key.txt
Give it a star on github: https://github.com/theninza/imcrypt
~ $
If you check, your find out in the output that imcrypt generated another key, this key is required to decrypt the image. Let's take a look at the image.
Just note that the key is an excessive large combination. If you have an image of 35 Kilobytes, the key can be up to 213 Kilobytes.
Decode the Image back
Now we've encrypted the image lets decode it back.The size of the image might change after decryption. So this is how to decrypt the latter:
root@kali : ~# npx imcrypt -d bike_e.png -k bike_key.txt -i <output_of_iamge>
imcrypt v1.0.1 by theninza
An image encryption node-js cli
✔ Image read successfully
✔ Key read successfully
✔ Decryption successful
✔ Image saved successfully
✔ Success Image decrypted successfully
Decrypted Image: bike_d.png
Give it a star on github: https://github.com/theninza/imcrypt
And the end sample, is the exact same replica of the original image.
Conculsion
Data Privacy is vitae cyber security role in fighting back. Data is never safe, so cryptography takes the data in a form not readable to human.Cryptography is the scrambling of dta to something useless with the encryptor being the only one able to access the ciphertext(encrypted data)