no-style-please2-plugins 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/enc.rb +25 -9
- data/lib/version/version.rb +1 -1
- data/test.rb +13 -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: 1481f05da7257deb43b4f2d8475d8e708e4bb3d4c31f23ca3f20580ee6ac60cf
|
4
|
+
data.tar.gz: df0238ad5567dc1ce3bb8e242b2258accf3ff65f752c007522dd1dea22f0f75f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a655d2b12c8c5ccfaedeeebb186b5c41438861c293d2fa3a89dd173e72f6945cf2af2767e8a3be4df5b0cd4ca9ed221559b6c046b7a9720a3bfdf1925b752f6
|
7
|
+
data.tar.gz: cec5db851784412d946b307f55fb374efdaade832752d96dff3027c59298989f9cf0e1e27a1a9e7c0b8130038511669cd09d8abfc98f849e85eec87ec8ac5154
|
data/Gemfile.lock
CHANGED
data/lib/enc.rb
CHANGED
@@ -94,6 +94,11 @@ module Jekyll
|
|
94
94
|
return "#{key}"
|
95
95
|
end
|
96
96
|
end
|
97
|
+
# 大端模式
|
98
|
+
def self.nmberToBinary4(num)
|
99
|
+
[num].pack("N")[0, 4]
|
100
|
+
end
|
101
|
+
|
97
102
|
module EncFilter
|
98
103
|
|
99
104
|
|
@@ -102,7 +107,7 @@ module Jekyll
|
|
102
107
|
str.unpack('C*').map{ |b| "%02x" % b }.join('')
|
103
108
|
end
|
104
109
|
|
105
|
-
def hex2bin(str)
|
110
|
+
def self.hex2bin(str)
|
106
111
|
[str].pack "H*"
|
107
112
|
end
|
108
113
|
def genKey(password)
|
@@ -171,30 +176,39 @@ module Jekyll
|
|
171
176
|
return bin2hex(OpenSSL::Random.random_bytes(n2))
|
172
177
|
end
|
173
178
|
|
179
|
+
|
174
180
|
def encrypt_content_v2(content,pswHex)
|
175
181
|
if !pswHex || pswHex.length != 64
|
176
182
|
raise "invalid Key:" + pswHex
|
177
183
|
end
|
178
|
-
cipher = OpenSSL::Cipher::AES.new(256, :
|
184
|
+
cipher = OpenSSL::Cipher::AES.new(256, :CTR).encrypt
|
179
185
|
iv = cipher.random_iv
|
180
186
|
cipher.iv = iv
|
181
|
-
cipher.key = hex2bin(pswHex)
|
187
|
+
cipher.key = EncFilter.hex2bin(pswHex)
|
182
188
|
encrypted = cipher.update(content) + cipher.final
|
183
|
-
return 'E2.' + Base64.strict_encode64(iv + encrypted )
|
184
|
-
end
|
185
189
|
|
190
|
+
|
191
|
+
len = 4 + iv.length + encrypted.length
|
192
|
+
lenBf = Jekyll.nmberToBinary4(len)
|
193
|
+
lenBf2 = lenBf.bytes.map.each_with_index do |v,i|
|
194
|
+
z = i ^ iv.bytes[i ]
|
195
|
+
v ^ z
|
196
|
+
end.pack('C*')
|
197
|
+
return Base64.strict_encode64(lenBf2 + iv + encrypted )
|
198
|
+
end
|
186
199
|
|
187
200
|
def encrypt_key(x,page,keyHex2Enc,encid)
|
188
201
|
arr = EncFilterTool.getAllKey(page)
|
189
202
|
newArr = arr.map do |k|
|
190
203
|
key = genKey encid + k + encid
|
191
204
|
hexKey = bin2hex key
|
192
|
-
encrypt_content_v2(hex2bin(keyHex2Enc),hexKey)
|
205
|
+
Base64.strict_decode64(encrypt_content_v2(EncFilter.hex2bin(keyHex2Enc),hexKey))
|
193
206
|
end
|
194
207
|
|
195
|
-
newArr.join
|
208
|
+
Base64.strict_encode64(newArr.join)
|
209
|
+
|
196
210
|
end
|
197
|
-
|
211
|
+
|
198
212
|
|
199
213
|
|
200
214
|
end
|
@@ -202,7 +216,9 @@ module Jekyll
|
|
202
216
|
|
203
217
|
Liquid::Template.register_filter(Jekyll::EncFilter)
|
204
218
|
|
205
|
-
|
219
|
+
class Test
|
220
|
+
extend EncFilter
|
221
|
+
end
|
206
222
|
|
207
223
|
|
208
224
|
|
data/lib/version/version.rb
CHANGED
data/test.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'openssl'
|
4
4
|
require 'base64'
|
5
|
+
require_relative "lib/enc"
|
5
6
|
$Key = {}
|
6
7
|
def genKey(password)
|
7
8
|
cache = $Key[password]
|
@@ -51,6 +52,8 @@ def decrypt(enstring,password)
|
|
51
52
|
end
|
52
53
|
|
53
54
|
|
55
|
+
|
56
|
+
|
54
57
|
msg = '我的 12a23007'
|
55
58
|
z = encrypt msg,'123'
|
56
59
|
puts z
|
@@ -64,4 +67,13 @@ genKey '123'
|
|
64
67
|
genKey '123'
|
65
68
|
genKey '123'
|
66
69
|
genKey '456'
|
67
|
-
|
70
|
+
|
71
|
+
puts '---'
|
72
|
+
a = Jekyll::nmberToBinary4(256)
|
73
|
+
puts a.unpack1('H*')
|
74
|
+
a = a.bytes.map.each_with_index do |byte,i | byte ^ i
|
75
|
+
end.pack('C*')
|
76
|
+
|
77
|
+
puts a.unpack1('H*')
|
78
|
+
|
79
|
+
puts Jekyll::Test.encrypt_content_v2('333333a','00000000000000052f5c9b07ebc4464717978b174c440573df03e2962d98946c')
|
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.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vitock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|