no-style-please2-plugins 0.7.4 → 0.8.0
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 +4 -4
- data/README.md +1 -1
- data/lib/enc.rb +77 -12
- data/lib/version/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb824516aa69202aeb751b710764aea4f7c8e352bfcf94fe7ee426c66f354a45
|
4
|
+
data.tar.gz: dd951357fe4e823aa00456d13814ae8815fbf40026318b0e132554564a28dbfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ffba3bbbe75ba9dcfb62e15d01ce34ac76ec3d3dcdd554f4244dc93093575c4fbb93e3a67859b00e2ceee476baff27d911fefdf4aedff851d63042287cf3e2
|
7
|
+
data.tar.gz: 58266e9e6dfd9767022640fdc5bad66a5876537e4dcb49c744fff3a09180fba54b02d71a4807841d747f761b75166097da4b83437c19da9fb529592464ca22f3
|
data/README.md
CHANGED
data/lib/enc.rb
CHANGED
@@ -5,9 +5,46 @@ require 'ltec'
|
|
5
5
|
require "jekyll"
|
6
6
|
require "fileutils"
|
7
7
|
module Jekyll
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
10
11
|
class EncFilterTool
|
12
|
+
def EncFilterTool.getAllKey(page)
|
13
|
+
site = Jekyll::sites[0]
|
14
|
+
keys = []
|
15
|
+
key = "#{page['key']}"
|
16
|
+
if key != nil && key.length > 0
|
17
|
+
keys << key
|
18
|
+
end
|
19
|
+
|
20
|
+
posttags = page["tags"]
|
21
|
+
enctags = site.config['enc_tags']
|
22
|
+
if posttags && posttags.length > 0 && enctags
|
23
|
+
|
24
|
+
for tag in posttags
|
25
|
+
for enctag in enctags
|
26
|
+
if enctag['tag'] == tag
|
27
|
+
key = "#{enctag['password']}"
|
28
|
+
keys << key
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
keys.map do |key|
|
34
|
+
if key.length > 50
|
35
|
+
pubkey = ENV["JEKYLL_EC_PRIVATEKEY"]
|
36
|
+
if pubkey == nil
|
37
|
+
raise 'JEKYLL_EC_PRIVATEKEY not set on envionment'
|
38
|
+
end
|
39
|
+
key = Ltec::EC.decrypt(pubkey,key)
|
40
|
+
|
41
|
+
if key == nil || key.length == 0
|
42
|
+
raise "key decription fail"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
key
|
46
|
+
end
|
47
|
+
end
|
11
48
|
def EncFilterTool.getKey(content,page)
|
12
49
|
site = Jekyll::sites[0]
|
13
50
|
key = "#{page['key']}"
|
@@ -59,7 +96,15 @@ module Jekyll
|
|
59
96
|
end
|
60
97
|
module EncFilter
|
61
98
|
|
99
|
+
|
62
100
|
$KeyMap = {}
|
101
|
+
def bin2hex(str)
|
102
|
+
str.unpack('C*').map{ |b| "%02x" % b }.join('')
|
103
|
+
end
|
104
|
+
|
105
|
+
def hex2bin(str)
|
106
|
+
[str].pack "H*"
|
107
|
+
end
|
63
108
|
def genKey(password)
|
64
109
|
cacheKey = $KeyMap[password]
|
65
110
|
if cacheKey
|
@@ -80,7 +125,7 @@ module Jekyll
|
|
80
125
|
cipher.iv = iv
|
81
126
|
cipher.key = genKey password
|
82
127
|
encrypted = cipher.update(msg) + cipher.final
|
83
|
-
return '
|
128
|
+
return 'E2.' + Base64.strict_encode64(iv + encrypted + cipher.auth_tag)
|
84
129
|
|
85
130
|
end
|
86
131
|
def get_encrypt_id(content,page)
|
@@ -92,7 +137,6 @@ module Jekyll
|
|
92
137
|
return ""
|
93
138
|
end
|
94
139
|
end
|
95
|
-
|
96
140
|
def encrypt_content(content,page,prefix)
|
97
141
|
psw = EncFilterTool.getKey(content,page)
|
98
142
|
psw = prefix + psw + prefix
|
@@ -123,6 +167,35 @@ module Jekyll
|
|
123
167
|
return ''
|
124
168
|
end
|
125
169
|
|
170
|
+
def rand_bytes(_,n2)
|
171
|
+
return bin2hex(OpenSSL::Random.random_bytes(n2))
|
172
|
+
end
|
173
|
+
|
174
|
+
def encrypt_content_v2(content,pswHex)
|
175
|
+
if !pswHex || pswHex.length != 64
|
176
|
+
raise "invalid Key:" + pswHex
|
177
|
+
end
|
178
|
+
cipher = OpenSSL::Cipher::AES.new(256, :CBC).encrypt
|
179
|
+
iv = cipher.random_iv
|
180
|
+
cipher.iv = iv
|
181
|
+
cipher.key = hex2bin(pswHex)
|
182
|
+
encrypted = cipher.update(content) + cipher.final
|
183
|
+
return 'E2.' + Base64.strict_encode64(iv + encrypted )
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
def encrypt_key(x,page,keyHex2Enc,encid)
|
188
|
+
arr = EncFilterTool.getAllKey(page)
|
189
|
+
newArr = arr.map do |k|
|
190
|
+
key = genKey encid + k + encid
|
191
|
+
hexKey = bin2hex key
|
192
|
+
encrypt_content_v2(hex2bin(keyHex2Enc),hexKey)
|
193
|
+
end
|
194
|
+
|
195
|
+
newArr.join('#')
|
196
|
+
end
|
197
|
+
|
198
|
+
|
126
199
|
|
127
200
|
end
|
128
201
|
|
@@ -131,14 +204,6 @@ Liquid::Template.register_filter(Jekyll::EncFilter)
|
|
131
204
|
|
132
205
|
|
133
206
|
|
134
|
-
def bin2hex(str)
|
135
|
-
str.unpack('C*').map{ |b| "%02x" % b }.join('')
|
136
|
-
end
|
137
|
-
|
138
|
-
def hex2bin(str)
|
139
|
-
[str].pack "H*"
|
140
|
-
end
|
141
|
-
|
142
207
|
|
143
208
|
|
144
209
|
end
|
data/lib/version/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: no-style-please2-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vitock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|