no-style-please2 0.7.5.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/_config.yml +1 -1
  3. data/_includes/encrypted.html +53 -36
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27d38035aa7549d0caed5b7df23925519f4cb0e893054c26300dc386438af4e0
4
- data.tar.gz: 189da46fbe29eb9920af72a160e27018c1cd3ef4f65b94c0323859517e6d5661
3
+ metadata.gz: 2c0380a5261d5da61615ac60d982f565abd4c29aea473be81123ded47c65da1a
4
+ data.tar.gz: c3581628085f7d9ac0d0b2d5399baa0d61da96c4fbf405986b75928aaffe0715
5
5
  SHA512:
6
- metadata.gz: df438c53973516bb779db624520ddac2cec84af6dd5bc1b7580e7dab92d869ba681d6397add34cd95f72b014bbea0b7ace7176406af01afac42f32ecd1175ffd
7
- data.tar.gz: '07893fa095359de05dbeea33016bc85f23311dd93aee588c246180e3be3872373e56249b6a36ad9889868d327dc22826f11a26d73e6efe112f716715f3304766'
6
+ metadata.gz: bcc8f939c61568ae7a261f1e6d5f1cdd080dd28a786106acb0f462630a9960ab06c5661522efc7c40691e775f72265a4044fb81d8f6baeb1daf4123e1c62a1e4
7
+ data.tar.gz: 9c980dcd91f580f2f7dbd4b11c51cab945efc86c67a9caf5451d08d3bc51d7f3af83596639580631e65bdf1d5c24f4a53c2938137696e308e9c93f31527ff624
data/_config.yml CHANGED
@@ -49,7 +49,7 @@ enc_tags:
49
49
  - tag: ZZ
50
50
  password: '1'
51
51
  - tag: encrypt1
52
- password: "123" # plain text ,not recommed
52
+ password: "12345" # plain text ,not recommed
53
53
 
54
54
  # do Not write you public or privatekey in your repo,
55
55
  # use ltectool g to generate a new one for your own blog
@@ -21,47 +21,59 @@
21
21
  <div id = 'decryptContent'>
22
22
  </div>
23
23
  </div>
24
- <script src="//cdn.jsdelivr.net/gh/vitock/jsdelivr@0.1.1/js/salsa20.min.js"></script>
25
- <script src="//cdn.jsdelivr.net/gh/vitock/jsdelivr@0.1.1/js/base64.js"></script>
26
- <script src="//cdn.jsdelivr.net/gh/vitock/jsdelivr@0.1.1/js/md5.js"></script>
24
+ <script>
25
+ var exports = exports || {}
26
+ </script>
27
+ <script src="//cdn.jsdelivr.net/gh/vitock/jsdelivr@0.1.2/js/base64js.js"></script>
27
28
  <script>
28
29
  !function(){
29
- const preFix = '{{encid}}';
30
- const encid = preFix
31
- var encryptedContent = '{{ content | encrypt_content:page, encid}}'
32
- const nonceStr = encryptedContent.substring(0,16);
33
- const msg = encryptedContent.substring(17)
34
-
35
- function hexToUint8Arr(hexString){
36
- return new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
37
- }
30
+
31
+ const substl = crypto.subtle
32
+ const preFix = '{{encid}}';
33
+ const encid = preFix
34
+ const encryptedContent = '{{ content | encrypt_content:page, encid}}'
35
+ const base64str = encryptedContent.substring(3)
36
+ const bfMsg = base64js.decode(base64str)
37
+ const bfIv = bfMsg.subarray(0,12)
38
+ const bfCipher = bfMsg.subarray(12)
39
+
40
+ async function genKey(psw){
41
+ var keyRaw = new TextEncoder().encode(psw)
42
+ var key = await substl.importKey('raw',keyRaw,'PBKDF2',false,["deriveBits"])
43
+ const salt = 'this is a salt string 20221019'
44
+ let pbkdf2 = {
45
+ name:"PBKDF2",hash: "SHA-256",iterations: 12345,salt: new TextEncoder().encode(salt)
46
+ }
47
+ return await substl.deriveBits(pbkdf2,key,256);
48
+ }
38
49
 
39
50
 
40
- function decrypt (key0,isCached){
51
+
52
+ async function decrypt (key0,isCached){
41
53
  // const key = Uint8Array([...]); // 32 bytes key
42
54
 
43
55
  var key = ''
44
- var keyDgst = ""
45
56
  if(isCached){
46
- keyDgst= key0
47
- key = new TextEncoder("utf-8").encode(keyDgst);
57
+ key = readKey()
48
58
  }
49
59
  else{
50
60
  var keyS = preFix + key0 + preFix
51
- keyDgst = md5(keyS)
52
- key = new TextEncoder("utf-8").encode(keyDgst);
61
+ key = await genKey(keyS)
53
62
  }
54
- var nonce = hexToUint8Arr(nonceStr)
55
-
56
-
57
- const message = Base64.toUint8Array(msg)
58
- // Encrypt //
59
- const decrypt = new JSSalsa20(key, nonce).decrypt(message);
60
- var plain = new TextDecoder("utf-8").decode(decrypt)
61
- var check = md5(plain)
62
- if(check.indexOf(nonceStr) == 0){
63
- setKey(keyDgst)
64
- /// hide input
63
+ if (key.length == 0) {
64
+ return
65
+ }
66
+
67
+ var aeskey = {
68
+ name:"AES-GCM",
69
+ length:256
70
+ }
71
+ var keyObj = await substl.importKey('raw',key,aeskey,false,['decrypt'])
72
+ var aesDec= {name: "AES-GCM",iv:bfIv,tagLength:128}
73
+ try {
74
+ var bfDec = await substl.decrypt(aesDec,keyObj,bfCipher)
75
+ var plain = new TextDecoder().decode(bfDec);
76
+ setKey(key)
65
77
  document.getElementById("encrypted").style.display = 'none'
66
78
  // / show decrypted
67
79
 
@@ -77,13 +89,11 @@
77
89
 
78
90
  window.dispatchEvent(loadevent)
79
91
  window.dispatchEvent(DOMContentLoaded_event)
80
- console.log('333a334a')
81
92
 
82
93
  }, 500);
83
-
84
- }else{
94
+ } catch (error) {
85
95
  alert("wrong password.")
86
- }
96
+ }
87
97
  }
88
98
 
89
99
  document.getElementById("DecryptBtn").onclick = function(){
@@ -130,11 +140,18 @@
130
140
  {% else %}
131
141
  function readKey(){
132
142
  var key = encid;
133
- return localStorage.getItem(key)
143
+ var v = localStorage.getItem(key)
144
+ if (v) {
145
+ return base64js.decode(v)
146
+ }else{
147
+ return null
148
+ }
134
149
  }
135
150
  function setKey(value){
136
151
  var key = encid
137
- return localStorage.setItem(key,value)
152
+ var arr = new Uint8Array(value)
153
+ var b64 = base64js.encode(arr)
154
+ return localStorage.setItem(key,b64)
138
155
  }
139
156
  function clearKey() {
140
157
  var key = encid
@@ -148,7 +165,7 @@
148
165
  {% endif %}
149
166
 
150
167
 
151
-
168
+
152
169
  }()
153
170
 
154
171
  </script>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: no-style-please2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vitock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-23 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.0
33
+ version: 0.5.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.0
40
+ version: 0.5.0
41
41
  description:
42
42
  email:
43
43
  - r