Skip to content

Instantly share code, notes, and snippets.

View lankanmon's full-sized avatar

Lankanmon Inc. lankanmon

View GitHub Profile
@lankanmon
lankanmon / drivingDistanceAndTime.gs
Created May 21, 2017 04:27
Find the distance (in KM or MI) and driving time between locations stored in Google Sheets. Distances and Time provided by Google Apps Script Maps Service.
/** drivingDistanceAndTime.gs **/
/** Find the distance (in KM or MI) and driving time between locations
stored in Google Sheets. Distances and Time provided by Google Apps Script Maps Service */
/** Note: This is built on top of Google App Scripts Code **/
/** Licensed under the Apache 2.0 License **/
/** By: Sandu Rajapakse - lankanmon **/
/** === USAGE INSTRUCTIONS ===
To use these functions in Google Sheets, place this code in a new script in the Script Editor.
<?php
/* There are many ways to use crypt() in PHP, but I have found this to be useful and practical. */
//For generating Salt:
$salt = substr(str_shuffle("./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345‌​6789"), 0, 8);
//or if you have a linux server, this is a much more random way of generating salt
$fp = fopen(''/dev/urandom'', ''r'');
$randomString = fread($fp, 32);
fclose($fp);
//Base 64 encode to ensure that some characters will not cause problems for crypt
$salt = base64_encode($randomString);