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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb824516aa69202aeb751b710764aea4f7c8e352bfcf94fe7ee426c66f354a45
4
- data.tar.gz: dd951357fe4e823aa00456d13814ae8815fbf40026318b0e132554564a28dbfd
3
+ metadata.gz: 1481f05da7257deb43b4f2d8475d8e708e4bb3d4c31f23ca3f20580ee6ac60cf
4
+ data.tar.gz: df0238ad5567dc1ce3bb8e242b2258accf3ff65f752c007522dd1dea22f0f75f
5
5
  SHA512:
6
- metadata.gz: d5ffba3bbbe75ba9dcfb62e15d01ce34ac76ec3d3dcdd554f4244dc93093575c4fbb93e3a67859b00e2ceee476baff27d911fefdf4aedff851d63042287cf3e2
7
- data.tar.gz: 58266e9e6dfd9767022640fdc5bad66a5876537e4dcb49c744fff3a09180fba54b02d71a4807841d747f761b75166097da4b83437c19da9fb529592464ca22f3
6
+ metadata.gz: 3a655d2b12c8c5ccfaedeeebb186b5c41438861c293d2fa3a89dd173e72f6945cf2af2767e8a3be4df5b0cd4ca9ed221559b6c046b7a9720a3bfdf1925b752f6
7
+ data.tar.gz: cec5db851784412d946b307f55fb374efdaade832752d96dff3027c59298989f9cf0e1e27a1a9e7c0b8130038511669cd09d8abfc98f849e85eec87ec8ac5154
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- no-style-please2-plugins (0.7.4)
4
+ no-style-please2-plugins (0.9.0)
5
5
  digest
6
6
  jekyll (~> 4.0)
7
7
  ltec (~> 0.1.2)
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, :CBC).encrypt
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NoStylePlease2
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
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
- puts $Key
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.8.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-14 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll