Google App Javascript Import of html

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    Google App Javascript Import of html

    Hi.

    Firstly apologies, but I'm experimenting and hope my question makes some kind of sense!

    I am trying to write a script for a google spreadsheet, and would like to import some crypto code from elsewhere.

    The code I would like to use is here. The home page, showing the usage is here.

    I have written some code to test the principle:
    Code:
    function endecode(){
    
      var sheet=SpreadsheetApp.getActiveSheet();
      var input=sheet.getRange(2, 1);
      var password=sheet.getRange(2,2);
      var encrypted=sheet.getRange(2,3);
      var decrypted=sheet.getRange(2,4);
    
    
    encrypted.setValue(CryptoJS.TripleDES.encrypt(input.getValue(), password.getValue()));
    decrypted.setValue(CryptoJS.TripleDES.decrypt(encrypted.getValue(), password.getValue()));
    
    };

    Obviously this doesn't work, because it doesn't recognize cryptoJS. But how can I import CryptoJS.

    I know almost nothing about JavaScript - my method is just to copy and edit snippets from elsewhere, which works fine since I'm generally doing very simple things!

    I even tried just copying the stuff from http://crypto-js.googlecode.com/svn/...s/tripledes.js straight into my function, but when I run it, there is a server error.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What's the server error? You shouldn't copy it into your function. It has functions of its own and those need to be declared outside any other function.

    Comment

    Working...