Title: Javascript encryption - need little help Post by: radhwane on March 12, 2018, 11:37:19 PM Greetings
im looking for little help with javascript encryption trying to encrypt my own chat platform and want to understand this code Code: var listConect = ['7', '2', '8', '4', '9', '6', '0', '5', '1', '3']; that mean the port is 36857 right ? ok lets say i want to change the port of my chat to another port like 35555 or anythings else what should be here ? Code: var init_port_h = conect + listConect[5] + listConect[2] + listConect[7] + listConect[0]; Title: Re: Javascript encryption - need little help Post by: DarkStar_ on March 13, 2018, 01:39:50 AM Why even bother going through all of this? This doesn't encrypt anything, and anyone remotely competent could easily see though the 'encryption' (more like scrambling, and even then, it's incredibly obvious).
If you wanted port 35555, you'd have Code: var init_port_h = conect + listConect[7] + listConect[7] + listConect[7] + listConect[7] Basically you have an array ['7', '2', '8', '4', '9', '6', '0', '5', '1', '3'] of values, and arrays start at zero, so you'd be taking values from the placement you request. listConect[5] would be requesting the 6th value, etc. Honestly, just do this: Code: var init_port_h = 35555 Title: Re: Javascript encryption - need little help Post by: Joel_Jantsen on March 13, 2018, 06:33:30 AM --snip-- I don't think you understand how encryption works.The following code is not only a bad example of using arrays to declare a constant but also shows how poor the approach is.1.Why would you want to encrypt the port number ? It is not very difficult to get the port number using any routing commands/tools. 2.If you wish to do it anyway,you have two options a.Write your own encryption algorithm method which you can call on your private constants like. Code: //Closure b.Use a third party library like crypto-js (https://github.com/brix/crypto-js) Ideally,you'd have something like Code: var CryptoJS = require("crypto-js"); |