Created
February 9, 2024 01:24
-
-
Save gjbianco/07b398c47661af7c86b1a2d9c78a9d2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>beef converter</title> | |
<meta name="viewport" content="width=device-width" /> | |
</head> | |
<body> | |
<h1>beef converter</h1> | |
<p>"translates" phrase to hexadecimal (invalid letters removed)</p> | |
<input type="text" id="phrase" placeholder="Input a phrase" /> | |
<br /> | |
<code id="output"></code> | |
<script> | |
(() => { | |
const phraseEl = document.querySelector("#phrase"); | |
const outputEl = document.querySelector("#output"); | |
const offset = " ".charCodeAt(0); | |
const charMap = | |
" ---------------0123456789-------ABCDEF--1--1--0---57-------"; | |
const processPhrase = (phrase) => | |
phrase | |
.toUpperCase() | |
.split("") | |
.map((i) => charMap[i.charCodeAt(0) - offset]) | |
.join("") | |
.replaceAll("-", ""); | |
phraseEl.addEventListener("input", () => { | |
outputEl.innerHTML = `0x${processPhrase(phraseEl.value)}`; | |
}); | |
phraseEl.dispatchEvent(new Event("input")); // run on page (re)load | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment