Encrypt & Decrypt text in Ruby

If you want to pass some information to a client that you don't want the client to read or temper with, read on!

The usage of our TextEncryptor is straightforward:

data = { ... }
serialized_data = JSON.dump(data)
encoded_data = TextEncryptor.encrypt(serialized_data)

# ...

serialized_data = TextEncryptor.decrypt(encoded_data)
data = JSON.parse(serialized_data)


One of the ways I use this is to store a proof that a phone number is verified on client side and allow exchanging that encoded phone number token to login or signup. You can read more about this in one of the following blog posts.

Thank you for reading!


Popular posts from this blog

Turbocharge HTTP requests in Ruby

Faster Google Maps load times

Ruby on Rails optimization techniques