Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

311
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!