FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feathernote/src/self-decrypting.html at alpine · royalgarter/feathernote · GitHub
royalgarter
/
feathernote
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
feathernote
/
src
/
self-decrypting.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
154 lines (145 loc) · 4.3 KB
Breadcrumbs
feathernote
/
src
/
self-decrypting.html
Copy path
File metadata and controls
154 lines (145 loc) · 4.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html
>
<
html
>
<
head
>
<
meta
charset
="
UTF-8
"
>
<
meta
name
="
viewport
"
content
="
width=device-width, initial-scale=1.0
"
>
<
title
>
Encrypted Note: {{TITLE}}
</
title
>
<
style
>
body
{
background-color
:
#
ffffff
;
color
:
#
000000
;
font-family
:
monospace;
margin
:
0
;
padding
:
2
rem
;
}
.
container
{
max-width
:
600
px
;
margin
:
4
rem
auto;
}
h1
{
font-size
:
1.5
rem
;
border-bottom
:
1
px
solid
#
000000
;
padding-bottom
:
0.5
rem
;
margin-top
:
0
;
}
p
{
line-height
:
1.5
;
}
.
input-group
{
margin-top
:
1.5
rem
;
}
input
[
type
=
"password"
] {
font-family
:
monospace;
padding
:
0.5
rem
;
font-size
:
1
rem
;
border
:
1
px
solid
#
000000
;
width
:
100
%
;
box-sizing
:
border-box;
margin-bottom
:
1
rem
;
outline
:
none;
}
button
{
font-family
:
monospace;
background-color
:
#
000000
;
color
:
#
ffffff
;
border
:
none;
padding
:
0.5
rem
1
rem
;
font-size
:
1
rem
;
cursor
:
pointer;
width
:
100
%
;
}
button
:
hover
{
background-color
:
#
333333
;
}
.
error-message
{
color
:
#
ff0000
;
margin-top
:
1
rem
;
display
:
none;
}
#
content
{
display
:
none;
max-width
:
600
px
;
margin
:
2
rem
auto;
padding
:
1
rem
;
border
:
solid black;
border-width
:
thin;
}
#
content
h1
{
font-size
:
1.5
rem
;
border-bottom
:
1
px
solid
#
000000
;
padding-bottom
:
0.5
rem
;
margin-top
:
2
rem
; }
#
content
h2
{
font-size
:
1.25
rem
;
margin-top
:
1.5
rem
; }
#
content
h3
{
font-size
:
1.1
rem
;
margin-top
:
1.2
rem
; }
#
content
p
{
line-height
:
1.5
;
margin-bottom
:
1
rem
; }
#
content
ul
,
#
content
ol
{
padding-left
:
2
rem
;
margin-bottom
:
1
rem
; }
#
content
li
{
margin-bottom
:
0.25
rem
; }
#
content
pre
{
background-color
:
#
f4f4f4
;
padding
:
1
rem
;
border
:
1
px
solid
#
000000
;
overflow-x
:
auto;
margin-bottom
:
1
rem
; }
#
content
code
{
font-family
:
monospace;
background-color
:
#
f4f4f4
;
padding
:
0.1
rem
0.3
rem
; }
#
content
blockquote
{
border-left
:
3
px
solid
#
000000
;
padding-left
:
1
rem
;
margin-left
:
0
;
font-style
:
italic; }
</
style
>
</
head
>
<
body
>
<
div
id
="
prompt
"
class
="
container
"
>
<
h1
>
Encrypted Note
</
h1
>
<
p
>
This note is password-protected. Enter the password to unlock it.
</
p
>
<
div
class
="
input-group
"
>
<
input
type
="
password
"
id
="
pwd
"
placeholder
="
Enter password
"
autofocus
/>
<
button
onclick
="
decryptAndShow()
"
>
Unlock Note
</
button
>
</
div
>
<
div
id
="
error-msg
"
class
="
error-message
"
>
Incorrect password. Please try again.
</
div
>
</
div
>
<
div
id
="
content
"
>
</
div
>
<
script
>
const
encryptedPayload
=
"{{ENCRYPTED_PAYLOAD}}"
;
const
textEncoder
=
new
TextEncoder
(
)
;
const
textDecoder
=
new
TextDecoder
(
)
;
async
function
deriveKey
(
password
,
salt
)
{
const
passwordBytes
=
textEncoder
.
encode
(
password
)
;
const
baseKey
=
await
crypto
.
subtle
.
importKey
(
'raw'
,
passwordBytes
,
'PBKDF2'
,
false
,
[
'deriveKey'
]
)
;
return
crypto
.
subtle
.
deriveKey
(
{
name
:
'PBKDF2'
,
salt
,
iterations
:
100000
,
hash
:
'SHA-256'
}
,
baseKey
,
{
name
:
'AES-GCM'
,
length
:
256
}
,
false
,
[
'encrypt'
,
'decrypt'
]
)
;
}
async
function
decrypt
(
combinedBase64
,
password
)
{
const
binString
=
atob
(
combinedBase64
)
;
const
len
=
binString
.
length
;
const
combinedBytes
=
new
Uint8Array
(
len
)
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
combinedBytes
[
i
]
=
binString
.
charCodeAt
(
i
)
;
}
const
salt
=
combinedBytes
.
slice
(
0
,
16
)
;
const
iv
=
combinedBytes
.
slice
(
16
,
28
)
;
const
ciphertextBytes
=
combinedBytes
.
slice
(
28
)
;
const
key
=
await
deriveKey
(
password
,
salt
)
;
const
decryptedBuffer
=
await
crypto
.
subtle
.
decrypt
(
{
name
:
'AES-GCM'
,
iv
}
,
key
,
ciphertextBytes
)
;
return
textDecoder
.
decode
(
decryptedBuffer
)
;
}
async
function
decryptAndShow
(
)
{
const
pwd
=
document
.
getElementById
(
'pwd'
)
.
value
;
if
(
!
pwd
)
return
;
const
errorMsg
=
document
.
getElementById
(
'error-msg'
)
;
errorMsg
.
style
.
display
=
'none'
;
try
{
const
decrypted
=
await
decrypt
(
encryptedPayload
,
pwd
)
;
document
.
getElementById
(
'prompt'
)
.
style
.
display
=
'none'
;
const
contentDiv
=
document
.
getElementById
(
'content'
)
;
contentDiv
.
innerHTML
=
decrypted
;
contentDiv
.
style
.
display
=
'block'
;
}
catch
(
e
)
{
console
.
error
(
e
)
;
errorMsg
.
style
.
display
=
'block'
;
document
.
getElementById
(
'pwd'
)
.
value
=
''
;
document
.
getElementById
(
'pwd'
)
.
focus
(
)
;
}
}
document
.
getElementById
(
'pwd'
)
.
addEventListener
(
'keypress'
,
(
e
)
=>
{
if
(
e
.
key
===
'Enter'
)
decryptAndShow
(
)
;
}
)
;
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL