-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
271 lines (260 loc) · 8.46 KB
/
index.html
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>Yattoo: Encoding Yat in Images</title>
<meta content="noindex, nofollow" name="robots">
<meta content="Sean O'Brien for Tari Labs, see https://github.com/tari-labs/yat-steganography" name="author">
<meta content="This demo uses steganography to encode a Yat in an image.">
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
<style>
body, html {
margin:0;
padding:0;
font-family:Arial,sans-serif;
color:#fff;
background-color:#090719
}
h1 {
color:#fff;
margin-bottom:10px;
}
h2 .yat-header {
margin-top:24px;
}
#main {
position:relative;
width:940px;
padding:20px;
margin:auto;
}
#right {
position:relative;
float:left;
margin:12px;
width:600px;
vertical-align:top;
}
#left {
position:relative;
float:left;
width:260px;
padding:12px;
margin-right:10px;
border-radius:6px;
border:3px solid #523df1;
}
.half {
position:relative;
display:inline-block;
width:49%;
}
#original {
vertical-align:top;
}
#messageArea {
width:100%;
}
#img, #cover {
width:220px;
}
.btns {
margin-top:15px;
margin-bottom:10px;
padding: 0 40px;
}
.btn {
padding:10px 20px 10px 20px;
-moz-border-radius:15px;
-o-border-radius:15px;
-webkit-border-radius:15px;
border-radius:15px;
border:2px solid #523df1;
cursor:pointer;
color:#fff;
background-color:#523df1;
width:50px;
text-align:center;
}
.btn:hover {
color:#fff;
background-color:#af0398;
border-color:#af0398
}
#download {
position:absolute;
top:47px;
left:4px;
padding:10px 5px 5px 3px;
width:110px;
border-top:1px solid #523df1;
-moz-border-radius:0 0 15px 15px;
-o-border-radius:0 0 15px 15px;
-webkit-border-radius:0 0 15px 15px;
border-radius:0 0 15px 15px;
text-decoration:none;
color:#fff;
}
#download:hover {
border-top:1px solid #af0398;
color:#fff;
width:110px;
}
#description {
color:#ccc;
line-height:25px;
padding-bottom:5px;
margin-bottom:24px;
}
.note {
font-size:9px;
text-align:center;
color:#fff;
}
.invisible {
visibility:hidden;
}
.clear {
clear:both;
}
.footer {
margin-top:25px;
width:100%;
text-align:right;
}
.footer img {
margin-left:80px;
border: none;
}
.footer:hover {
opacity:.8;
}
textarea{
width:200px;
padding:10px;
height:48px;
resize:none;
font-size:1.8em;
background:#000;
border-radius:6px;
border:2px solid #af0398;
}
h2{
margin-top:0;
}
</style>
</head>
<body>
<div id="main">
<h1>Yattoo: Encoding Yat in Images</h1>
<div id="description">
This demo uses steganography to encode a Yat in an image. It is fully client-side and in-browser, utilizing JavaScript and the HTML5 Canvas element to write to the alpha channel of the image. This technique opens a wide variety of use cases for Yat in watermarking, identification, authentication, or new NFT products such as Yat-branded Gems or PFPs. Steganography can also be accomplished via least-significant bit (LSB) or F5 algorithm depending on the use case and security requirements.
</div>
<div id="left">
<h2>Choose Image:</h2><input id="file" type="file"><br>
<h2 class="yat-header">Yat:</h2>
<textarea cols="5" id="text" maxlength="" rows="5">✨✨🐔✨✨</textarea>
<div class="btns">
<span class="btn" id="hide">Write</span> <span class="btn" id="read">Read</span>
</div>
</div>
<div id="right">
<div class="half" id="original">
<h2>Plain Image:</h2><img id="img" src="img/chicken.png" alt="Plain Image"></div>
<div class="half" id="stego">
<h2>Encoded Image:</h2><img id="cover" src="" alt="Encoded Image"> <a class="btn small" id="download" rel="nofollow"><strong>🔻 Download</strong></a>
<div class="note">
If button does not work, right-click to download
</div>
</div>
<div class="invisible" id="messageArea">
<h2>Yat:</h2>
<div id="message"></div>
</div>
</div>
<div class="clear"></div>
<div class="footer"><a href="https://y.at" target="_blank"><img src="img/logo-yat-white.png" alt="Yat"></a><a href="https://github.com/tari-labs/yat-steganography" target="_blank"><img src="img/github-mark-white.png" alt="Github"></a></div>
</div>
<script src="js/steganography.js" type="text/javascript">
</script>
<script type="text/javascript">
function handleFileSelect(evt) {
var original = document.getElementById("original"),
stego = document.getElementById("stego"),
img = document.getElementById("img"),
cover = document.getElementById("cover"),
message = document.getElementById("message");
if(!original || !stego) return;
var files = evt.target.files; // FileList object
// Loop through FileList and render image files as thumbnails
for (var i = 0, f; f = files[i]; i++) {
// Only process image files
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
// Capture the file information
reader.onload = (function(theFile) {
return function(e) {
img.src = e.target.result;
img.title = escape(theFile.name);
stego.className = "half invisible";
cover.src = "";
message.innerHTML="";
message.parentNode.className="invisible";
updateCapacity();
};
})(f);
// Read the image file as a data URL
reader.readAsDataURL(f);
}
}
function hide() {
var stego = document.getElementById("stego"),
img = document.getElementById("img"),
cover = document.getElementById("cover"),
message = document.getElementById("message"),
textarea = document.getElementById("text"),
download = document.getElementById("download");
if(img && textarea) {
cover.src = steg.encode(textarea.value, img);
stego.className = "half";
message.innerHTML="";
message.parentNode.className="invisible";
download.href=cover.src.replace("image/png", "image/octet-stream");
}
}
function read() {
var img = document.getElementById("img"),
cover = document.getElementById("cover"),
message = document.getElementById("message"),
textarea = document.getElementById("text");
if(img && textarea) {
message.innerHTML = steg.decode(img);
if(message.innerHTML !== "") {
message.parentNode.className="";
textarea.value = message.innerHTML;
updateCapacity();
}
}
}
function updateCapacity() {
var img = document.getElementById('img'),
textarea = document.getElementById('text');
if(img && text)
document.getElementById('capacity').innerHTML='('+textarea.value.length + '/' + steg.getHidingCapacity(img) +' chars)';
}
window.onload = function(){
document.getElementById('file').addEventListener('change', handleFileSelect, false);
document.getElementById('hide').addEventListener('click', hide, false);
document.getElementById('read').addEventListener('click', read, false);
document.getElementById('text').addEventListener('keyup', updateCapacity, false);
hide();
updateCapacity();
};
</script>
</body>
</html>