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.
- checksums.yaml +4 -4
- data/_config.yml +1 -1
- data/_includes/encrypted.html +53 -36
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c0380a5261d5da61615ac60d982f565abd4c29aea473be81123ded47c65da1a
|
4
|
+
data.tar.gz: c3581628085f7d9ac0d0b2d5399baa0d61da96c4fbf405986b75928aaffe0715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: "
|
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
|
data/_includes/encrypted.html
CHANGED
@@ -21,47 +21,59 @@
|
|
21
21
|
<div id = 'decryptContent'>
|
22
22
|
</div>
|
23
23
|
</div>
|
24
|
-
<script
|
25
|
-
|
26
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
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
|
-
|
47
|
-
key = new TextEncoder("utf-8").encode(keyDgst);
|
57
|
+
key = readKey()
|
48
58
|
}
|
49
59
|
else{
|
50
60
|
var keyS = preFix + key0 + preFix
|
51
|
-
|
52
|
-
key = new TextEncoder("utf-8").encode(keyDgst);
|
61
|
+
key = await genKey(keyS)
|
53
62
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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.
|
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.
|
40
|
+
version: 0.5.0
|
41
41
|
description:
|
42
42
|
email:
|
43
43
|
- r
|