jekyll-hash 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 57db1ecd180fa5dea5af353997ea7e6bbdff4995d8fb2a218bcb12d301ee858d
4
+ data.tar.gz: 5b6854b88e11c3a6843667754a7d0f668e45cee0b73d9688481593e23ced4af6
5
+ SHA512:
6
+ metadata.gz: 1d2d699fd047aff3d2ae8f796e496bf2a0714a12eeacfcfb16a09182e49b2878fd4ad69f89442489a4817cc00dd14e28c00f2488558d0e0b6e4495cf4b267862
7
+ data.tar.gz: e402f7b51694afecdbf9d48cfeff29a8c77e12cfee6198cddd41f6e5e0c16b36a77d3c5799b51660ec043961e0389965fbbe7222ea3535a7d0453c029ce3b718
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Jekyll Hash Filter
2
+
3
+ Adds a variety of filters to enable string hashing in Jekyll.
4
+
5
+ Currently the filter supports the following hash functions:
6
+
7
+ - SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256
8
+ - SHA3-224, SHA3-256, SHA3-384, SHA3-512
9
+
10
+ This plugin uses the OpenSSL implementations of the above hash functions.
11
+
12
+ ## Installation
13
+
14
+ Add the following to your `Gemfile`:
15
+
16
+ ```
17
+ gem 'jekyll-hash`
18
+ ```
19
+
20
+ Then make the following entry under `_config.yml`:
21
+
22
+ ```
23
+ plugins:
24
+ - jekyll-hash
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ The filters can be used as follows:
30
+
31
+ ```
32
+ {{ 'text to be hashed' | sha_256 }}
33
+ {{ 'text to be hashed' | sha_512_224 }}
34
+ {{ 'text to be hashed' | sha3_512 }}
35
+ ```
36
+
37
+ ## Testing
38
+
39
+ Run the command:
40
+
41
+ ```
42
+ bundle exec rspec
43
+ ```
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module HashFilter
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require "openssl"
2
+
3
+ module Jekyll
4
+ module HashFilter
5
+ # SHA
6
+ def sha_224(input)
7
+ OpenSSL::Digest.new('SHA224').hexdigest(input)
8
+ end
9
+
10
+ def sha_256(input)
11
+ OpenSSL::Digest.new('SHA256').hexdigest(input)
12
+ end
13
+
14
+ def sha_384(input)
15
+ OpenSSL::Digest.new('SHA384').hexdigest(input)
16
+ end
17
+
18
+ def sha_512(input)
19
+ OpenSSL::Digest.new('SHA512').hexdigest(input)
20
+ end
21
+
22
+ def sha_512_224(input)
23
+ OpenSSL::Digest.new('SHA512-224').hexdigest(input)
24
+ end
25
+
26
+ def sha_512_256(input)
27
+ OpenSSL::Digest.new('SHA512-256').hexdigest(input)
28
+ end
29
+
30
+ # SHA3
31
+ def sha3_224(input)
32
+ OpenSSL::Digest.new('SHA3-224').hexdigest(input)
33
+ end
34
+
35
+ def sha3_256(input)
36
+ OpenSSL::Digest.new('SHA3-256').hexdigest(input)
37
+ end
38
+
39
+ def sha3_384(input)
40
+ OpenSSL::Digest.new('SHA3-384').hexdigest(input)
41
+ end
42
+
43
+ def sha3_512(input)
44
+ OpenSSL::Digest.new('SHA3-512').hexdigest(input)
45
+ end
46
+ end
47
+ end
48
+
49
+ Liquid::Template.register_filter(Jekyll::HashFilter)
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+
3
+ describe(Jekyll::HashFilter) do
4
+ let(:output) do
5
+ render_liquid(content, {'str' => str})
6
+ end
7
+
8
+ # SHA
9
+ context "SHA-224" do
10
+ let(:str) { "SHA-224 test string" }
11
+ let(:content) { "{{ '#{str}' | sha_224 }}" }
12
+
13
+ it "produces the correct SHA-224 hash" do
14
+ expect(output).to eq("b61c3d89346ccb3f54018d43a88942b2284292ea99a953674b1d2d98")
15
+ end
16
+ end
17
+
18
+ context "SHA-256" do
19
+ let(:str) { "SHA-256 test string" }
20
+ let(:content) { "{{ '#{str}' | sha_256 }}" }
21
+
22
+ it "produces the correct SHA-256 hash" do
23
+ expect(output).to eq("7b5f93b25e76daa39830a7591d40750f656fafdde5efb9bb4b7a4fa00cc37227")
24
+ end
25
+ end
26
+
27
+ context "SHA-384" do
28
+ let(:str) { "SHA-384 test string" }
29
+ let(:content) { "{{ '#{str}' | sha_384 }}" }
30
+
31
+ it "produces the correct SHA-384 hash" do
32
+ expect(output).to eq("ea0378d51cc1679f525194895515930af035f1e7677ad558f6823927a64bb0e33dd60cf14eca0d5504edacae1b780529")
33
+ end
34
+ end
35
+
36
+ context "SHA-512" do
37
+ let(:str) { "SHA-512 test string" }
38
+ let(:content) { "{{ '#{str}' | sha_512 }}" }
39
+
40
+ it "produces the correct SHA-512 hash" do
41
+ expect(output).to eq("9faedb0bbb45bc01cc37b5c645c3136c949d482c0e6d9aeba0f63630570f0c5d4866e441b462eda8fbba21f41d47be69deb2a467111a989771820def5dcbd1df")
42
+ end
43
+ end
44
+
45
+ context "SHA-512/224" do
46
+ let(:str) { "SHA-512/224 test string" }
47
+ let(:content) { "{{ '#{str}' | sha_512_224 }}" }
48
+
49
+ it "produces the correct SHA-512/224 hash" do
50
+ expect(output).to eq("503941a788a47dedbec6e857f917ce28d1fdbd8b59c8bba24fe78634")
51
+ end
52
+ end
53
+
54
+ context "SHA-512/256" do
55
+ let(:str) { "SHA-512/256 test string" }
56
+ let(:content) { "{{ '#{str}' | sha_512_256 }}" }
57
+
58
+ it "produces the correct SHA-512/256 hash" do
59
+ expect(output).to eq("26756c84af30abf395e4973b4c6f3c1e2499fbb77df7e08d6659737fd30158ed")
60
+ end
61
+ end
62
+
63
+ # SHA3
64
+ context "SHA3-224" do
65
+ let(:str) { "SHA3-224 test string" }
66
+ let(:content) { "{{ '#{str}' | sha3_224 }}" }
67
+
68
+ it "produces the correct SHA3-224 hash" do
69
+ expect(output).to eq("f560c1381a3a81fb674f26cee8f2030570032ce6094dac84a0478afb")
70
+ end
71
+ end
72
+
73
+ context "SHA3-256" do
74
+ let(:str) { "SHA3-256 test string" }
75
+ let(:content) { "{{ '#{str}' | sha3_256 }}" }
76
+
77
+ it "produces the correct SHA3-256 hash" do
78
+ expect(output).to eq("c6d803ea0394cae943e1d70660d34511870a2b6395cf6222857c197e51db6103")
79
+ end
80
+ end
81
+
82
+ context "SHA3-384" do
83
+ let(:str) { "SHA3-384 test string" }
84
+ let(:content) { "{{ '#{str}' | sha3_384 }}" }
85
+
86
+ it "produces the correct SHA3-384 hash" do
87
+ expect(output).to eq("75684296cbbc768de02c251814f41288b47e902e1466efebe90352e436a77b2af7710fafef3bc3ebfc15ad4e4c1b408f")
88
+ end
89
+ end
90
+
91
+ context "SHA3-512" do
92
+ let(:str) { "SHA3-512 test string" }
93
+ let(:content) { "{{ '#{str}' | sha3_512 }}" }
94
+
95
+ it "produces the correct SHA3-512 hash" do
96
+ expect(output).to eq("d326751d4c34d9805e65ec39202dc5c7fdbc98d73923510fa13ceef8942986b701089eaacd5bb3d61d0517afd4ef724a64e5b2341a36c78582845155b58c0bb7")
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,15 @@
1
+ TEST_DIR = File.dirname(__FILE__)
2
+
3
+ require 'liquid'
4
+ require File.expand_path("../lib/jekyll-hash.rb", TEST_DIR)
5
+
6
+ RSpec.configure do |config|
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ config.order = 'random'
10
+
11
+ def render_liquid(content, variables)
12
+ template = Liquid::Template.parse(content)
13
+ template.render(variables)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-hash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Harrison McCarty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: liquid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.2.26
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.2.26
55
+ description: Message digest filter for Jekyll
56
+ email:
57
+ - mccarth@purdue.edu
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.md
63
+ - lib/jekyll-hash.rb
64
+ - lib/jekyll-hash/version.rb
65
+ - spec/jekyll-hash_spec.rb
66
+ - spec/spec_helper.rb
67
+ homepage: https://github.com/hmccarty/jekyll-hash
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.9.3
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.7.6
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: This plugin provides a simple liquid filter which converts strings to crptographically
91
+ secure hashes.
92
+ test_files:
93
+ - spec/spec_helper.rb
94
+ - spec/jekyll-hash_spec.rb