Bitcoin Forum
September 23, 2018, 11:12:31 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Javascript encryption - need little help  (Read 43 times)
radhwane
Hero Member
*****
Offline Offline

Activity: 689
Merit: 500


Twelve Chat free online chat rooms


View Profile WWW
March 12, 2018, 11:37:19 PM
 #1

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'];
var conect = listConect[9];
var init_port_h = conect + listConect[5] + listConect[2] + listConect[7] + listConect[0];

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];

1537744351
Hero Member
*
Offline Offline

Posts: 1537744351

View Profile Personal Message (Offline)

Ignore
1537744351
Reply with quote  #2

1537744351
Report to moderator
1537744351
Hero Member
*
Offline Offline

Posts: 1537744351

View Profile Personal Message (Offline)

Ignore
1537744351
Reply with quote  #2

1537744351
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1537744351
Hero Member
*
Offline Offline

Posts: 1537744351

View Profile Personal Message (Offline)

Ignore
1537744351
Reply with quote  #2

1537744351
Report to moderator
1537744351
Hero Member
*
Offline Offline

Posts: 1537744351

View Profile Personal Message (Offline)

Ignore
1537744351
Reply with quote  #2

1537744351
Report to moderator
1537744351
Hero Member
*
Offline Offline

Posts: 1537744351

View Profile Personal Message (Offline)

Ignore
1537744351
Reply with quote  #2

1537744351
Report to moderator
DarkStar_
Legendary
*
Offline Offline

Activity: 1092
Merit: 1331

:D


View Profile WWW
March 13, 2018, 01:39:50 AM
Merited by mprep (1)
 #2

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

Joel_Jantsen
Legendary
*
Offline Offline

Activity: 1092
Merit: 1185


Hand over the Merit and no one will get hurt!


View Profile
March 13, 2018, 06:33:30 AM
 #3

--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
  function(portNumber) {
      return {
          ownEncryptionAlgo: function() {
              //returns encrypted constant
          }
      }
  }
 

b.Use a third party library like crypto-js
Ideally,you'd have something like
Code:
var CryptoJS = require("crypto-js");

// Encrypt
let portNumber = CryptoJS.AES.encrypt('port_num', 'secret key 123');

// Decrypt
let decryptedPort  = CryptoJS.AES.decrypt(portNumber.toString(), 'secret key 123');
let plaintext = decryptedPort.toString(CryptoJS.enc.Utf8);


.BitDice.               ▄▄███▄▄
           ▄▄██▀▀ ▄ ▀▀██▄▄
      ▄▄█ ▀▀  ▄▄█████▄▄  ▀▀ █▄▄
  ▄▄██▀▀     ▀▀ █████ ▀▀     ▀▀██▄▄
██▀▀ ▄▄██▀      ▀███▀      ▀██▄▄ ▀▀██
██  ████▄▄       ███       ▄▄████  ██
██  █▀▀████▄▄  ▄█████▄  ▄▄████▀▀█  ██
██  ▀     ▀▀▀███████████▀▀▀     ▀  ██
             ███████████
██  ▄     ▄▄▄███████████▄▄▄     ▄  ██
██  █▄▄████▀▀  ▀█████▀  ▀▀████▄▄█  ██
██  ████▀▀       ███       ▀▀████  ██
██▄▄ ▀▀██▄      ▄███▄      ▄██▀▀ ▄▄██
  ▀▀██▄▄     ▄▄ █████ ▄▄     ▄▄██▀▀
      ▀▀█ ▄▄  ▀▀█████▀▀  ▄▄ █▀▀
           ▀▀██▄▄ ▀ ▄▄██▀▀
               ▀▀███▀▀
        ▄▄███████▄▄
     ▄███████████████▄
    ████▀▀       ▀▀████
   ████▀           ▀████
   ████             ████
   ████ ▄▄▄▄▄▄▄▄▄▄▄ ████
▄█████████████████████████▄
██████████▀▀▀▀▀▀▀██████████
████                   ████
████                   ████
████                   ████
████                   ████
████                   ████
████▄                 ▄████
████████▄▄▄     ▄▄▄████████
  ▀▀▀█████████████████▀▀▀
        ▀▀▀█████▀▀▀
▄▄████████████████████████████████▄▄
██████████████████████████████████████
█████                            █████
█████                            █████
█████                            █████
█████                            █████
█████                     ▄▄▄▄▄▄▄▄▄▄
█████                   ▄█▀▀▀▀▀▀▀▀▀▀█▄
█████                   ██          ██
█████                   ██          ██
█████                   ██          ██
██████████████████▀▀███ ██          ██
 ████████████████▄  ▄██ ██          ██
   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ██          ██
             ██████████ ██          ██
           ▄███████████ ██████▀▀██████
          █████████████  ▀████▄▄████▀
[/]
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!