Last active
July 4, 2025 18:43
-
-
Save ViniciusFXavier/a44b29830ae691287882f6eb66231a40 to your computer and use it in GitHub Desktop.
Ofuscar código JavaScript
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
function encodeChar(ch) { | |
const lo = ch.charCodeAt(0) & 0xFF; | |
// U+1F600 até U+1F6FF são emojis de faces e similares | |
const codePoint = 0x1F600 + lo; | |
return String.fromCodePoint(codePoint); | |
} | |
// Ofusca a string de entrada | |
function obfuscate(input) { | |
let obf = ''; | |
for (const ch of input) { | |
obf += encodeChar(ch); | |
} | |
// 1) escape transforma cada emoji em "%uD83D%uDEXX" | |
// 2) replace remove as partes do surrogate pair: | |
// - "uD83D" (parte alta) e "uDE.." (parte baixa deixando "%XX") | |
// 3) unescape converte "%XX" de volta ao caractere original | |
return `unescape(escape("${obf}").replace(/uD83D..../g, ''))`; | |
} |
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
function encodeChar(ch) { | |
const lo = ch.charCodeAt(0) & 0xFF; | |
// U+2600 até U+26FF são símbolos/emoji em BMP | |
// U+2800 são símbolos/emoji em pontos | |
return String.fromCharCode(0x2600 + lo); | |
} | |
// Ofusca a string de entrada | |
function obfuscate(input) { | |
let obf = ''; | |
for (const ch of input) { | |
obf += encodeChar(ch); | |
} | |
// 1) escape transforma cada \u26LL em "%u26LL" | |
// 2) replace(/u../g, '') remove "u26", deixando "%LL" | |
// 3) unescape converte "%LL" de volta ao caractere original | |
return `unescape(escape("${obf}").replace(/u../g, ''))`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment