1.0.11 • Published 10 months ago

storeimage v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Image Storage and Retrieval

This Node.js module provides functions to store and retrieve image data as binary and Base64 encrypted format using AES encryption. It utilizes the fs module for file operations and crypto-js library for encryption.

Installation

To use this module, you need to have Node.js installed on your system. Then you can install the module via npm: npm install --save image-storage-retrieval

Usage `const fs = require('fs'); const { storeImageAsBinary, retrieveImageAsBase64 } = require('image-storage-retrieval');

// Your custom storage function for storing the encrypted data async function customStorageFunction(encryptedData) { // Your implementation to store the encrypted data (e.g., in a database or file) // ... }

// Your custom retrieval function for retrieving the encrypted data async function customRetrievalFunction() { // Your implementation to retrieve the encrypted data (e.g., from a database or file) // ... }

// Example usage to store an image as binary data (async () => { try { const imageFilePath = '/path/to/your/image.jpg'; await storeImageAsBinary(imageFilePath, customStorageFunction, { encryptionKey: 'your-secret-encryption-key', // Optional: Provide your encryption key }); } catch (error) { console.error('Error storing the image:', error); } })();

// Example usage to retrieve the image as Base64 data (async () => { try { const base64ImageData = await retrieveImageAsBase64(customRetrievalFunction, { encryptionKey: 'your-secret-encryption-key', // Optional: Provide your encryption key }); console.log('Base64 Image Data:', base64ImageData); } catch (error) { console.error('Error retrieving the image:', error); } })(); `

API

storeImageAsBinary(imageFilePath, storageFunction, options) Stores the image as binary data in an encrypted format.

imageFilePath (string): The path to the image file to be stored. storageFunction (async function): A custom function that takes the encrypted image data as a parameter and stores it. options (object, optional): Additional options for the storage process. encryptionKey (string, optional): The encryption key to use for AES encryption. If not provided, the default key will be used. retrieveImageAsBase64(retrievalFunction, options) Retrieves the image as Base64 data.

retrievalFunction (async function): A custom function that retrieves the encrypted image data. options (object, optional): Additional options for the retrieval process. encryptionKey (string, optional): The encryption key to use for AES decryption. If not provided, the default key will be used. License

This module is licensed under the MIT License. Feel free to use it and contribute to its development!

1.0.11

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago