All Projects → metaware → Underlock

metaware / Underlock

Licence: mit
Underlock makes it dead simple to encrypt and decrypt your data and files. It comes with little to no dependencies and has a very small API surface.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Underlock

Hybrid Crypto Js
RSA+AES hybrid encryption implementation for JavaScript. Works with Node.js, React Native and modern browsers.
Stars: ✭ 87 (-32.03%)
Mutual labels:  encryption, decryption, encrypt
Laravel Database Encryption
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Stars: ✭ 238 (+85.94%)
Mutual labels:  encryption, decryption, encrypt
Openssl
TLS/SSL and crypto library
Stars: ✭ 17,157 (+13303.91%)
Mutual labels:  encryption, openssl, decryption
Cryptr
A simple shell utility for encrypting and decrypting files using OpenSSL.
Stars: ✭ 81 (-36.72%)
Mutual labels:  encryption, openssl, decryption
Gonnacry
A Linux Ransomware
Stars: ✭ 341 (+166.41%)
Mutual labels:  encryption, openssl, decryption
Wolfssl
wolfSSL (formerly CyaSSL) is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3!
Stars: ✭ 1,098 (+757.81%)
Mutual labels:  encryption, openssl
Simple Polymorphic Engine Spe32
Simple Polymorphic Engine (SPE32) is a simple polymorphic engine for encrypting code and data. It is an amateur project that can be used to demonstrate what polymorphic engines are.
Stars: ✭ 59 (-53.91%)
Mutual labels:  encryption, decryption
Lazysodium Android
An Android implementation of the Libsodium cryptography library. For the lazy dev.
Stars: ✭ 69 (-46.09%)
Mutual labels:  encryption, decryption
Hat.sh
encrypt and decrypt files in your browser. Fast, Secure client-side File Encryption and Decryption using the web crypto api
Stars: ✭ 886 (+592.19%)
Mutual labels:  encryption, decryption
Simon speck ciphers
Implementations of the Simon and Speck Block Ciphers
Stars: ✭ 74 (-42.19%)
Mutual labels:  encryption, decryption
Open Crypto
🔑 Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation.
Stars: ✭ 115 (-10.16%)
Mutual labels:  encryption, openssl
Enigma
Gradle Plugin - Obfuscator String Encryption (Android/Java)
Stars: ✭ 43 (-66.41%)
Mutual labels:  encryption, encrypt
Horizoncrypt
Animal Crossing: New Horizons Save Encryptor/Decryptor
Stars: ✭ 36 (-71.87%)
Mutual labels:  encryption, decryption
Helm Secrets
DEPRECATED A helm plugin that help manage secrets with Git workflow and store them anywhere
Stars: ✭ 1,129 (+782.03%)
Mutual labels:  encryption, decryption
Iocane
An odorless, tasteless NodeJS crypto library that dissolves instantly in liquid
Stars: ✭ 35 (-72.66%)
Mutual labels:  encryption, decryption
Sharedchamber
Android Secure SharedPreferences Using Facebook Conceal Encryption
Stars: ✭ 96 (-25%)
Mutual labels:  encryption, decryption
Dcrypt
🔐A petite library of encryption functions for PHP
Stars: ✭ 93 (-27.34%)
Mutual labels:  encryption, openssl
Easycrypt
Android cryptography library with SecureRandom patches.
Stars: ✭ 102 (-20.31%)
Mutual labels:  encryption, decryption
Cryption
In-Browser AES File Encryption 🔐 with Data Integrity Check 🔍
Stars: ✭ 114 (-10.94%)
Mutual labels:  encryption, decryption
Enigma
Enigma cipher tool
Stars: ✭ 13 (-89.84%)
Mutual labels:  encryption, decryption

Underlock

Underlock makes it dead simple to encrypt and decrypt your data and files. It comes with little to no dependencies and has a very small API surface.

Gem Version Code Climate Build Status

Installation

Add this line to your application's Gemfile:

gem 'underlock'

And then execute:

$ bundle

Or install it yourself as:

$ gem install underlock

Initialization

Underlock::Base.configure do |config|
  config.public_key  = File.read('./key.pub')
  config.private_key = File.read('./key.priv')
  config.cipher      = OpenSSL::Cipher.new('aes-256-gcm')
end

For the config.cipher value, all algorithms available in OpenSSL::Cipher.ciphers are supported.

Important Note: Choose your algorithm carefully and stick to it. It'll kind of suck to be not able to decrypt your encrypted data.

Generating Public/Private keypair

key = OpenSSL::PKey::RSA.new 4096
puts key.to_pem
puts key.public_key.to_pem

Usage

Encrypting Strings/Text

irb> Underlock::Base.encrypt("super secret message")
=> #<Underlock::EncryptedEntity:0x007fef2e4b8320>

Underlock::EncryptedEntity has the following 3 methods

encrypted_entity.value
encrypted_entity.key
encrypted_entity.iv # iv stands for initialization vector

You should persist or store the key and iv in order to be able to decrypt the encrypted value.

Decrypting Strings/Text

  • Create an instance of Underlock::EncryptedEntity, use the key and iv collected in the previous steps.
irb> encrypted_entity = Underlock::EncryptedEntity.new(value: value, key: key, iv: iv)
  • Decrypt using one of the following methods:
irb> encrypted_entity.decrypt
irb> Underlock::Base.decrypt(encrypted_entity)

Encrypting Files

To encrypt files, instead of passing a String object, pass a File object to Underlock::Base.encrypt

irb> file = File.open('/path/to/your/secret/file.txt')
irb> Underlock::Base.encrypt(file)
=> #<Underlock::EncryptedEntity:0x007fef2e4b8320>

The return value is an instance of Underlock::EncryptedEntity and has the following methods:

encrypted_entity.encrypted_file
encrypted_entity.key
encrypted_entity.iv # iv stands for initialization vector here

#encrypted_file returns a File object. This file is saved in the same directory as your original file.

Decrypting Files

  • Create an instance of Underlock::EncryptedEntity, use the key and iv collected in the previous steps.
irb> file = File.open('/path/to/your/secret/file.txt.enc')
irb> encrypted_entity = Underlock::EncryptedEntity.new(encrypted_file: file, key: key, iv: iv)
  • Decrypt using one of the following methods:
irb> encrypted_entity.decrypt
irb> Underlock::Base.decrypt(encrypted_entity)

Following naming scheme is followed when encrypting/decrypting files:

original file name encrypted file name decrypted file name
file.pdf file.pdf.enc file.decrypted.pdf

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/metaware/underlock.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].