Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
Opinion on hiding string in js files, by shuffling the string

I am little bored and I though I would try something.

I was wondering how I could hide a string in js file. So I build a tool that would create a shuffling array and insert the string in there.

Then I would scatter the buildering of the string in different files, and building it again.

Now I though about it and could not help but wonder is this necessary when using it in react-native and react

here have a look and tell me what you think

const shuffle= (text, tohex) => {
  function ConvertStringToHex(str) {
    var arr = [];
    for (var i = 0; i < str.length; i++) {
      arr[i] = ('00' + str.charCodeAt(i).toString(16)).slice(-4);
    }
    return '\\u' + arr.join('\\u');
  }

  function shuffleArray(data) {
    let array = [...data];
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
  }

  const strArray = []
  for (let i = 0; i < text.length; i++) {
    const c = tohex === true? `'${ConvertStringToHex(text.charAt(i))}'`: `'${text.charAt(i)}'`
    const name = `v${c.replace(/'|\\/g, "")}l`;  


    strArray.push({
      index: strArray.find((x) => x.name === name)?.index | i,   
      name: name,
      file: !strArray.find((x) => x.name === name)
        ? `${c}`
        : '',
    }); 
  }
  const variable = "_0x" + Math.floor(text.length * (Math.random() * text.length))
  const data = strArray;
  var shuffledData = shuffleArray(strArray.filter((x) => x.file !== ''));
  let rClass = 'const ' + variable +'= [' + shuffledData.map(x=> x.file).join(",")+"]"; 
  rClass += `\nexport default ${data.reduce((arr, v) =>{
      var item = shuffledData.findIndex(x=> x.name === v.name);
      if (item !== -1)
            arr.push(variable+`[` + ('0X' + item.toString(16).toUpperCase()).slice(-4) +"]" )
      return arr;
  }, []).join('+')}`;  
  return rClass; 
};


const ts = "kjhasd "; 
console.log(shuffle(ts, false))

Now the idea is that export default _0x19[0X1]+_0x19[0X0]+_0x19[0X3]+_0x19[0X2]+_0x19[0X4]+_0x19[0X6]+_0x19[0X5] wont be in one file but in many other files with different imported names., that will be scattered, and then combined to one result string. This will make sure that others wont be able to read the string when opening the bundle js

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda