Bitcoin Forum
May 13, 2024, 11:32:44 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Javascript encryption - need little help  (Read 123 times)
radhwane (OP)
Hero Member
*****
Offline Offline

Activity: 696
Merit: 500



View Profile
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];
1715643164
Hero Member
*
Offline Offline

Posts: 1715643164

View Profile Personal Message (Offline)

Ignore
1715643164
Reply with quote  #2

1715643164
Report to moderator
1715643164
Hero Member
*
Offline Offline

Posts: 1715643164

View Profile Personal Message (Offline)

Ignore
1715643164
Reply with quote  #2

1715643164
Report to moderator
1715643164
Hero Member
*
Offline Offline

Posts: 1715643164

View Profile Personal Message (Offline)

Ignore
1715643164
Reply with quote  #2

1715643164
Report to moderator
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
DarkStar_
Legendary
*
Offline Offline

Activity: 2758
Merit: 3282


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

taking a break - expect delayed responses
Joel_Jantsen
Legendary
*
Offline Offline

Activity: 1876
Merit: 1308

Get your game girl


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

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!