--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.
//Closure
function(portNumber) {
return {
ownEncryptionAlgo: function() {
//returns encrypted constant
}
}
}
b.Use a third party library like
crypto-js Ideally,you'd have something like
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);