Now I will post the code more clearly and add an extension to encrypt the data.
1.- Create a TinyWebDB database with a PHP file.
We upload this file to our hosting:
tinywebdb.php
<?php
// Juan Antonio Villalpando
// http://kio4.com/appinventor/8A_MiniWebDB_TinyWebDB.htm
$receive_post = $_SERVER["REQUEST_URI"];
$tag = $_POST['tag'];
$file = 'tinywebdb.htm';
// If file not exist, create.
if (!file_exists($file)) {$create = fopen($file, 'w');}
if(strpos($receive_post,'storeavalue')){
//////////////////////////////// If exist that tag, DELETE it
//// to avoid repeating that tag.
$arc = file($file);
$auxi = fopen($file,"w");
foreach($arc as $line)
{ $fields = explode(":", $line);
if ($fields[0] != $tag) { fputs($auxi, $line); }
}
fclose($auxi);
/////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// STORE TAG AND VALUE
$valueToStore = $_POST['value'];
$line = $tag.":".$valueToStore.":\n";
$auxi = fopen($file, 'a'); // Add $line to file tinywebdb.htm
fwrite($auxi, $line);
} else {
///////////////////////////////////////////////////////////////////////////////////////////////////
// GET VALUE OF TAG.
// Search in file tinywebdb.htm value for that tag.
$auxi = fopen($file, 'r');
$exist = "";
while(!feof($auxi)){
$line = fgets($auxi);
$fields = explode(":", $line);
if ($fields[0] == $tag) {
$value =$fields[1];
$exist = true;
}
}
// Sends result.
if ($exist){ $result = array("VALUE", $tag, $value);} // Send value
else { $result = array("VALUE", $tag, "Not_found");} // Send "Not_found".
$result_in_JSON = json_encode($result);
echo $result_in_JSON;
}
fclose($auxi);
?>
We place a TinyWebDB component and in Property ServiceURL we put the internet address of the tinywebdb.php file, example: https://mydomain/tinywebdb.php
We can use the TinyWebDB component as we normally do.
In cryptography, a salt is random data that is used as an additional input to a one-way function that hashes data, a password or passphrase. Salts are used to safeguard passwords in storage. Historically a password was stored in plaintext on a system, but over time additional safeguards developed to protect a user’s password against being read from the system. A salt is one of those methods. A new salt is randomly generated for each password. In a typical setting, the salt and the password (or i…
This extension cipher the KeySecret by adding Salt and with that key encodes the data in Base 64