EntropySink
Technical & Scientific => Programming => Topic started by: Rob on February 26, 2013, 08:13:04 AM
-
Can one of you kind Java / Javascript experts interpret what this segment of code does please?
(Not what the functionality is, but literally what functions are being called, with what parameters etc.)
function SecureContext(strText, strSignature, bEscape) {
this.strSIGNATURE = strSignature || '';
this.bESCApE = bEscape || false;
this.strText = strText;
this.escape = SecureContext_escape;
this.unescape = SecureContext_unescape;
this.transliterate = SecureContext_transliterate;
this.encypher = SecureContext_encypher;
this.decypher = SecureContext_decypher;
this.sign = SecureContext_sign;
this.unsign = SecureContext_unsign;
this.secure = SecureContext_secure;
this.unsecure = SecureContext_unsecure;
}
If it helps, it's from here (http://www.inet.hr/~tsereg/en/jse/security.js) ( http://www.inet.hr/~tsereg/en/jse/index.html )
Ta!
edit>> It's these kind of lines I don't understand..
this.secure = SecureContext_secure;
Is that calling SecureContext_secure ? If so, where are the parameters? Surely it should be passing strPassword?
function SecureContext_secure( strPasswd )
{
var passwd = new Password( strPasswd );
var anPerm = passwd.getPermutation()
this.sign( anPerm.length );
this.transliterate( true );
this.encypher( anPerm );
}
-
No, it's not calling it. It is setting a reference to it. So that
foo = new SecureContent(stuff)
foo.secure(more stuff)
invokes SecureContext_secure
Think function pointer.
-
OK, thank you. That makes perfect sense.