Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dscheg committed Feb 28, 2024
1 parent 1a2c8ee commit 09f0751
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
9 changes: 4 additions & 5 deletions aes.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ input {

#mode-img {
transition: 0.2s filter linear;
background: 10px 0 / contain no-repeat;
filter: drop-shadow(0px 0px 10px #07f);
filter: drop-shadow(2px 4px 6px #222);
background: 10px center / contain no-repeat;
position: relative;
width: 99%;
translate: 0 -4px;
transform: scaleY(1.1);
translate: 0 -6px;
}
.night #mode-img {
filter: drop-shadow(0px 0px 10px #f50);
filter: drop-shadow(2px 4px 6px #f50);
}
#mode-img.mode-CBC-Decryption {
background-image: url("modes/CBC_decryption.min.svg");
Expand Down
13 changes: 4 additions & 9 deletions aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,13 @@ $cipher.addEventListener("change", e => {

$xor.addEventListener("change", e => {
const data = $xor.getData();
if((data.length & 15) !== 0) {
setResult(false, "Size must be multiple to AES block size");
return;
}

let result = new Uint8Array(16);
for(var row = 0; row < (data.length >> 4); row++)
for(var col = 0; col < 16; col++) {
result[col] ^= data[(row << 4) + col];
}
for(var idx = 0; idx < data.length; idx++)
result[idx & 15] ^= data[idx];

setResult(true, toHex(result).replace(/([0-9A-F]{2})/ig, '$1 '));
$("#xor-hex").value = toHex(result).replace(/([0-9A-F]{2})(?=.)/ig, '$1 ');
$("#xor-right").value = Array.from(result).map(c => String.fromCodePoint(c + (0x20 <= c && c < 0x7F ? 0 : 0xF000))).join('');
}, false);

$plain.setDataHex(localStorage.getItem("hex") || toHex(new TextEncoder().encode('{"name":"hack"}')));
2 changes: 1 addition & 1 deletion hex.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $$(".xed").forEach($xed => {
.map(c => String.fromCodePoint(c + (0x20 <= c && c < 0x7F ? 0 : 0xF000)))
.join('').replace(/(.{16})(?=.)/g, '$1\n');

$size.textContent = 'size=' + len;
$size.textContent = 'len=' + len;

const newpos = pos > 0 && [' ', '\n'].includes($hex.value[pos - 1]) ? pos - 1 : pos;
$hex.setSelectionRange(newpos, newpos);
Expand Down
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ <h3 class="grayed">XOR Lines</h3>
<td><textarea class="xed-hex" cols=47 wrap="off" spellcheck="false"></textarea>
<td><textarea class="xed-right" cols=16 wrap="off" spellcheck="false"></textarea></td>
</tr>
<tr>
<td></td>
<td><textarea id="xor-hex" cols=47 wrap="off" spellcheck="false" readonly></textarea>
<td><textarea id="xor-right" cols=16 wrap="off" spellcheck="false" readonly></textarea></td>
</tr>
</table>

<h3>Result</h3>
Expand Down

0 comments on commit 09f0751

Please sign in to comment.