Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mimadottech/ipfs-crypt
Add files to IPFS with encryption
https://github.com/mimadottech/ipfs-crypt
Last synced: 29 days ago
JSON representation
Add files to IPFS with encryption
- Host: GitHub
- URL: https://github.com/mimadottech/ipfs-crypt
- Owner: mimadottech
- License: mit
- Created: 2020-08-15T04:28:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-15T10:14:28.000Z (over 4 years ago)
- Last Synced: 2024-10-10T20:53:44.367Z (2 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ipfs-crypt
> Add file to ipfs with encryption and cat back decrypted file.
- aes-256-ctr encryption algorithm
- custom Initialization Vector for each encrypted value
- HMAC/constant time compare to prevent tampering[![NPM Version][npm-image]][npm-url]
## Install
```bash
npm i @kyc-crypto/ipfs-crypt
```## Usage Example
```javascript
const crypto = require('crypto')
const { IpfsCrypt } = require('@kyc-crypto/ipfs-crypt')const key = crypto.randomBytes(32).toString('hex');
const hmacKey = crypto.randomBytes(32).toString('hex');// initialize IpfsCrypt
const ipfsCrypt = new IpfsCrypt(
{
key,
hmacKey,
host: 'ipfs.infura.io',
port: '5001',
protocol: 'https'
}
);// Add and cat file
(async () => {
try {
console.log('uploading file...')// Adding file to ipfs
const file = await ipfsCrypt.add(fs.readFileSync('./document.png'))
console.log('file', file)// Get decrypted buffer
const decryptedBuffer = await ipfsCrypt.cat(file.path)// Write buffer to file
fs.writeFileSync('./document.dec.png', decryptedBuffer)console.log('done!')
} catch (error) {
console.log(error)
}
})()
```
**Package also exports ipfs-http-client**
```javascript
const { IpfsHttpClient } = require('@kyc-crypto/ipfs-crypt')
```## License
[MIT](https://github.com/KYCCrypto/ipfs-crypt/blob/master/LICENSE)
[npm-image]: https://img.shields.io/npm/v/@kyc-crypto/ipfs-crypt.svg?style=for-the-badge&logo=npm&color=32CD32
[npm-url]: https://www.npmjs.com/package/@kyc-crypto/ipfs-crypt