App Inventor and HTML/JavaScript with Input Parameters


App Inventor and HMAC-SHA1 Encryption

Note: with the extension feature, this solution is now obsolete. Thank you MIT!
Now you can use my Tools Extension instead.


Let's encrypt! I downloaded these JavaScripts from crypto-js which do the encryption and conversion to base64. A html file accesses these scripts to supply a HMAC-SHA1 hash in base64 format back to App Inventor. The 3 files used will be downloaded to your device on first run of the app, see also the Webprefetch File by File download example.
To test if the calculation is correct, you can compare with an Online Hash Converter. Issue 244 and Issue 553 are no issues anymore!

App Inventor Blocks

Do you need help with your App Inventor project?

I can help you: for one hour I charge 25 USD.
Please contact me at info [at] puravidaapps [dot] com for details!
For questions about App Inventor, please use the App Inventor forum. Thank you.

Screenshot

HTML/JavaScript

<!DOCTYPE HTML>
<html>
<head>
  <meta name="author" content="puravidaapps.com">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>Encryption</title>
  <script src="hmac-sha1.js"></script>
  <script src="enc-base64-min.js"></script>
</head>

<body>
  <script>
    get parameter from the window.AppInventor object and split at | 
    var urlArray = window.AppInventor.getWebViewString().split("|");

    // do the encryption
    var hash = CryptoJS.HmacSHA1(urlArray[0], urlArray[1]);

    print the result to the window.AppInventor object
    window.AppInventor.setWebViewString(hash.toString(CryptoJS.enc.Base64));
  </script>
</body>
</html>

Miscellaneous

Download


If you find this example helpful and you are using it in one of your projects,
be nice and donate a small amount!

Donation amount:

or donate some mBTC to Bitcoin Address:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Bitcoin

Thank you! Taifun
 

Download aia file for App Inventor
Back to top of page ...

Creative Commons License
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.


Home | Snippets | Tutorials | Extensions | News | Forums | Links | Search | Contact