New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

octosecret-crypto

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

octosecret-crypto

Encryption lib for octosecret

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

octosecret-crypto

CircleCI Known Vulnerabilities NSP Status

Encrypt and decrypt data using RSA keys

What

Nodejs library that wraps openSSL to provide encryption and decryption of files and buffers. This was originally created to provide the crypto layer of octosecret, a CLI that allows easy data encryption and decryption between github users.

Features

  • Encrypt and decrypt files
  • Encrypt and decrypt streams (eg: text, buffer..)
  • Encryption support multiple keys

Install

npm install octosecret-crypto --save

API

File operations:

  • file.encrypt(origin, destination, keys)
  • file.decrypt(origin, destination, [key])

Stream operations:

  • stream.encrypt(data, keys)
  • stream.decrypt(data, [key])

Utils:

  • util.randomSymmetricKey(bytes)
  • util.createEncryptionKey(keys)
  • util.rsa2pkcs8(origin, destination)
  • util.rsaEncrypt(data, pkcs8_file)
  • util.rsaDecrypt(data, privateKey)
  • util.base64Encode(data)
  • util.base64Decode(data)
  • util.fileEncrypt(origin, destination, key)
  • util.fileDecrypt(origin, destination, key)
  • util.bufferEncrypt(buffer, key)
  • util.bufferDecrypt(buffer, key)

Examples

Encrypt and decrypt files

const octosecret = require('octosecret-crypto')

// Encrypt "octocat.gif" to "octocat.gif.octosecret" using "public.key"
await octosecret.file.encrypt(`octocat.gif`, `octocat.gif.octosecret`, ['public.key'])

// Decrypt "octocat.gif.octosecret" to "octocat.gif" using "id_rsa" key
await octosecret.file.decrypt(`octocat.gif.octosecret`, `octocat.gif`, `~/.ssh/id_rsa`)

Encrypt and decrypt streams

const octosecret = require('octosecret-crypto')

// Example data
const dataToEncrypt = "Super secret message"

// Encrypt
const encrypted = await octosecret.stream.encrypt(dataToEncrypt, ['public.key'])

// Decrypt
const decrypted = await octosecret.stream.decrypt(encrypted, `~/.ssh/id_rsa`)

// Convert Buffer to String
const decryptedText = decrypted.toString()
// "Super secret message"

Check __test__ and src/example.js for more examples

License

MIT © Hugo Rodrigues

FAQs

Package last updated on 14 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc