Skip to content

Typescript API to encrypt and decrypt any type of file (using AES256 encryption)

License

Notifications You must be signed in to change notification settings

AChandel01071994/file-encryption-decryption-in-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

File Encryption & Decryption in nodejs

Typescript API to encrypt and decrypt any type of file (using AES256 encryption) with compression enabled

Requirements

  • node >= 10

Installation & Dependencies

npm install zlib app-root-path uuid

Usage

Place file-service.ts file into you service folder and import the FileService class inside your controller/service to use it

import FileService from './file-service';

// file object received from multer
const fileObject = req.files['aadharCardImage'][0];

// encrypt and save the file
await FileService.Instance.saveFile(fileObject, FileService.Instance.bucket.uploads, 'image', 'invalid aadhar card image')

// decrypt and send to user
async getFiles(req: Request, res: Response, next: NextFunction): Promise<void> {
  await FileService.Instance.decryptAndSend(FileService.Instance.bucket.uploads, 'filename.png', res)
}

// delete file
await FileService.Instance.deleteFile(FileService.Instance.bucket.uploads, 'filename.png')

TODO

Publish as a npm package

About

Typescript API to encrypt and decrypt any type of file (using AES256 encryption)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages