Content Encryption with Jekyll

Easy to use way to encrypt your content and then decrypt it on client with password

May 17, 2018 - 2 minute read -
jekyll

Jekyll is a very powerful static site generator, and due to it’s static nature we actually doesn’t have a way to distribute our content with some kind of hidden way (or make content accessible whenever someone get paid for it).

So, after a quick look into available solutions i haven’t find anything useful, so i decided to make something simple by myself.

There are a plugins, that you can use with your Jekyll builds. What is necessary for now, whenever you are putting a Ruby file into _plugins folder, it being interpreted as one of plugins.

Here is plugin that i have made:

Actually it does declare a new Liquid tag called encrypted

Liquid::Template.register_tag('encrypted', Jekyll::Tags::EncryptionTag)

After that in your post you could do something like:


<div id="encrypted" style='word-break: break-all;'>
{% encrypted test-encryption/body.md key='your_key' %}
</div>

<script>
    var _gj = {
        salt: '{{ salt }}',
        iv: '{{ iv }}'
    }
</script>

So in your test-encryption/body.md will be a content under encryption.

Also, there is one more part to cover, how we can actually do an decryption part from browser? I do this part like this:

So if you will put your key in to document URL hash like this #your_key, your content will be decrypted