Giter Club home page Giter Club logo

amank04 / npm-encrypt-image Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kumaryogesh17/npm-encrypt-image

0.0 0.0 0.0 9 KB

"encrypt-image" is a lightweight Node.js module that provides a simple and secure way to encrypt image files. With just one command "npm i encrypt-image", you can easily install this module and start encrypting your images in no time

Home Page: https://www.npmjs.com/package/encrypt-image

JavaScript 100.00%

npm-encrypt-image's Introduction

How to use

Step - 1

Import the library

import { image } from "encrypt-image";

Step - 2

Generate keys using generateKeys() function and it will return public key , private key and symmetric key.

const keys = image.generateKeys();

Step - 3

use encrypt() function and pass the image , public key and symmetric key.

const encryptedImage = image.encrypt(image, keys.publicKey, keys.symmetricKey);

use decrypt function to get the original image , in this function just pass private key (keys.privateKey)

const encryptedData = fs.readFileSync('encrypted.bin');

const decryptedImage = image.decrypt(encryptedData,keys.privateKey);

can store decrypted image file using writeFileSync Function

fs.writeFileSync('decrepted.jpg',decryptedImage);

Example of encryption and decryption of image :

import { image } from "encrypt-image";
import fs from 'fs'

const keys = image.generateKeys();

const img = fs.readFileSync('image.jpg')

const encryptImage = image.encrypt(img, keys.publicKey, keys.symmetricKey);

const decryptedImage = image.decrypt(encryptedData,keys.privateKey);

fs.writeFileSync('dec.jpg',decryptedImage);

Example of encryption and decryption of Text :

import { text } from "encrypt-image";

const Keys = text.generateKeys();
const plaintext = "Hi this Encryption";
const encryptedText = text.encrypt(plaintext, Keys.publicKey);

console.log(encryptedText);

const decryptedText = text.decrypt(encryptedText,Keys.privateKey);

console.log(decryptedText);

npm-encrypt-image's People

Contributors

kumaryogesh17 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.