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

For questions about App Inventor,
please ask in the App Inventor community.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


Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to 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 | Links | Search | Privacy Policy | Contact