0
function encryption(ciphers, value, key, var_iv){
        if(ciphers == 'aes'){
            alert(CryptoJS.AES.encrypt(value, key, {iv:var_iv}));
            //^The var_iv above is not the value given to the parameter "561564848945123132123145564", instead its just "var_iv".
        }
    encryption("aes", "foo", "passcrytp", "561564848945123132123145564", "CBC", "ZeroPadding");

Can't seem to pass the function parameter inside the curly bracket for mome reason. Help please. (:

Im not tring to access object property, I'm trying to pass the value given to the function parameter, to inside curly brackets mention above.

toastext
  • 325
  • 3
  • 12
  • 1
    Are you asking about property accessors? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors – elclanrs Mar 27 '16 at 20:07
  • Your code looks fine... Maybe you're passing the wrong parameters to CryptoJS libary's encrypt method? Or you mean this -> CryptoJS.mode[var_mode] (note square brackets) – George Kagan Mar 27 '16 at 20:08
  • `CryptoJS.mode.var_mode` — Looks like you really mean "How can I access a property when I have its name in a variable?" – Quentin Mar 27 '16 at 20:08
  • 1
    Might be a dup: https://stackoverflow.com/questions/4244896/dynamically-access-object-property-using-variable not voting though since it would close – Andreas Louv Mar 27 '16 at 20:09
  • yea and sorry, I'm wasn't sure how to explaine it. :/ – toastext Mar 27 '16 at 20:09
  • going to re-write the question, it just seem to vauge – toastext Mar 27 '16 at 20:12
  • @timeNomad no it not, the var_mode, does get the value, it just var_mode, instead of "CBC", in the parameter. – toastext Mar 27 '16 at 20:29

0 Answers0