Installation | Encryption Example | Initialization | Documentation | Support
Virgil Security provides a set of APIs for adding security to any application. In a few simple steps you can encrypt communication, securely store data, provide passwordless login, and ensure data integrity.
For a full overview head over to our Ruby Get Started guides.
The Virgil SDK is provided as a gem named virgil-sdk. The package is distributed via bundler package manager.
The gem is available for Ruby 2.1 and newer.
Installing the gem
To install package use the command below:
gem install virgil-sdk
or add the following line to your Gemfile:
gem 'virgil-sdk', '~> 4.2.6'
Next: Get Started with the Ruby SDK.
Virgil Security makes it super easy to add encryption to any application. With our SDK you create a public Virgil Card for every one of your users and devices. With these in place you can easily encrypt any data in the client.
require "virgil/sdk"
include Virgil::SDK::HighLevel
# initialize Virgil SDK
virgil = VirgilApi.new(access_token: "[YOUR_ACCESS_TOKEN_HERE]")
# find Alice's card(s)
alice_cards = virgil.cards.find("alice")
# encrypt the message using Alice's cards
message = "Hello Alice!"
encrypted_message = alice_cards.encrypt(message)
# transmit the message with your preferred technology
transmit_message(encrypted_message.to_base64)
The receiving user then uses their stored private key to decrypt the message.
# load Alice's Key from storage.
alice_key = virgil.keys.load("alice_key_1", "mypassword")
# decrypt the message using the key
original_message = alice_key.decrypt(transfer_data).to_s
Next: To get you properly started you'll need to know how to create and store Virgil Cards. Our Get Started guide will get you there all the way.
Also: Encrypted communication is just one of the few things our SDK can do. Have a look at our guides on Encrypted Storage, Data Integrity and Passwordless Login for more information.
To use this SDK you need to sign up for an account and create your first application. Make sure to save the app id, private key and it's password. After this, create an application token for your application to make authenticated requests from your clients.
To initialize the SDK on the client side you will only need the access token you created.
virgil = VirgilApi.new(access_token: "[YOUR_ACCESS_TOKEN_HERE]")
Note: this client will have limited capabilities. For example, it will be able to generate new Cards but it will need a server-side client to transmit these to Virgil.
To initialize the SDK on the server side we will need the access token, app id and the App Key you created on the Developer Dashboard.
# initialize Virgil SDK high-level instance.
context = VirgilContext.new(
access_token: "[YOUR_ACCESS_TOKEN_HERE]",
# Credentials are required only in case of publish and revoke local Virgil Cards.
credentials: VirgilAppCredentials.new(app_id: "[YOUR_APP_ID_HERE]",
app_key_data: VirgilBuffer.from_file("[YOUR_APP_KEY_PATH_HERE]"),
app_key_password: "[YOUR_APP_KEY_PASSWORD_HERE]")
)
virgil = VirgilApi.new(context: context)
Next: Learn more about our the different ways of initializing the Ruby SDK in our documentation.
Virgil Security has a powerful set of APIs, and the documentation is there to get you started today.
- Get Started documentation
- Guides
This library is released under the 3-clause BSD License.
Our developer support team is here to help you. You can find us on Twitter and email.