Calculate #PHP equivalent #MD5 Hash in MS #SQL Server

md5

The MD5 hash is a pretty standard and secure hashing algorithm, that is often used to create one-way encryption of sensitive data. Quite often the hash code is generated from the application layer, such as PHP, and needs to be verified at the database layer.

So, let’s say you want to hash the word “password” in SQL server – you just write

select CONVERT(varchar(max),HASHBYTES(‘MD5’, ‘password’),2)

which results in

5F4DCC3B5AA765D61D8327DEB882CF99

Possibly the least secure password in the world!

 

Categories: Uncategorized

#Austrian #NatCode API for #BMVIT

KONICA MINOLTA DIGITAL CAMERA

Austria has a system of NatCode id numbers (“Nationaler Code”) developed by Eurotax / Glasss’ that uniquely identifies each make and model of vehicle within for Road tax purposes, and this is now available via an API at http://www.natcode.at

The data can be downloaded in bulk for import into your own database via the following link:  https://payhip.com/b/tS0x

The Austrian API accepts Eurotax NatCode (Nationaler Code) numbers instead of number plates. A NatCode is a unique number under which is registered with the BMVIT.

This API is accessed via the /CheckAustria endpoint, where NatCode is an integer. It returns the following data:

  • Make & Model
  • Engine Size in KW and HorsePower (PS)
  • Engine Capacity
  • Indicative price (new)
  • Date range
  • Transmission
  • Representative image

Sample KBA Number:

223089

Sample Json:

{
“Description”: “Abarth Abarth 124 Spider Aut. “,
“CarMake”: {
“CurrentTextValue”: “Abarth ”
},
“CarModel”: {
“CurrentTextValue”: “Abarth 124 Spider”
},
“MakeDescription”: {
“CurrentTextValue”: “Abarth ”
},
“ModelDescription”: {
“CurrentTextValue”: “Abarth 124 Spider”
},
“PowerKW”: 125,
“PowerHP”: 169,
“EngineSize”: 1368,
“IndicativeValue”: 44000,
“DateRange”: “2016”,
“ImageUrl”: “http://www.natcode.at/image.aspx/@QWJhcnRoICBBYmFydGggMTI0IFNwaWRlcg==”
}

Categories: Uncategorized

Get #GooglePlus Profile page from #Email

25ba7

If you want to get a person’s Google Plus profile page from their email address, here is the trick to do it.

  1. Get the user’s profile picture from AvatarAPI.com
  2. Take the digits between the last forward-slash “/” and the dot “.”

So, for instance, if you wanted to get the Google Plus page of “peter.smith@gmail.com”, you plug this into AvatarAPI, and you get

lh3.googleusercontent.com/-06yJmZ9VFKI/AAAAAAAAAAI/AAAAAAAAAAA/KHOss3osMJ4/s181-c/117841766777955842390.jpg

Where 117841766777955842390 is the Google Plus Profile ID.

You can navigate to the Google Plus Profile page now using

https://plus.google.com/117841766777955842390

Categories: Uncategorized

#KBA API for Germany based on #Kraftfahrt-Bundesamt data

GERMANY-AUTOMOBILE-VOLKSWAGEN-RECALL

We just launched KbaAPI.de this morning, which is an API that allows a lookup of the German KBA (“Kraftfahrt-Bundesamt”) data. Unlike other countries in the network, the German API accepts KBA numbers instead of number plates.

The data can be purchased as a CSV import for your own database here https://payhip.com/b/PqsL

A KBA number (“Kraftfahrt-Bundesamt”) is a unique number under which is registered with the Federal Motor Transport Authority. The KBA number can be found on the vehicle registration in boxes 2 and 3 or in the registration certificate Part 1 under 2.1.
and 2.2. This API is accessed via the /CheckGermany endpoint, where KBANumber is in the format HSN/TSN (Herstellerschlüsselnummer / Typschlüsselnummer), it returns the following data:
● Make & Model
● Engine Size in KW and HorsePower (PS)
● Engine Capacity
● Fuel type
● Representative image
Sample KBA Number:
4000/305
Sample Json:
{
“Description”: “ALFA GIULIETTA Spider 1.3 [196101 – 196212] (59kW 80hp Otto AR 00508)”,
“CarMake”: {
“CurrentTextValue”: “alfa romeo”
},
“CarModel”: {
“CurrentTextValue”: “GIULIETTA SPIDER”
},
“MakeDescription”: {
“CurrentTextValue”: “alfa romeo”
},
“ModelDescription”: {
“CurrentTextValue”: “GIULIETTA SPIDER”
},
“PowerKW”: 59,
79
“PowerHP”: 80,
“EngineSize”: 1281,
“Fuel”: “Benzin”,
“ImageUrl”:
http://www.kbaapi.de/image.aspx/@YWxmYSByb21lbyBHSVVMSUVUVEEgU1BJREVS”
}

Categories: Uncategorized

#Jquery #Ajax progress indicator

68747470733a2f2f7261772e6769746875622e636f6d2f4b656e616469612f63697263756c61722d70726f67726573732d696e64696361746f722f6d61737465722f73637265656e73686f742e706e67

If you are using JQuery Ajax to upload a file, or other large blob of data, you might want to show the user that something is happening, rather than just showing an animated gif.

Here’s a JQuery Plugin by Chad Engler which can extend the default $.ajax behavior to report progress updates as a percentage.

(function ($, window, undefined) {
//is onprogress supported by browser?
var hasOnProgress = (“onprogress” in $.ajaxSettings.xhr());

//If not supported, do nothing
if (!hasOnProgress) {
return;
}

//patch ajax settings to call a progress callback
var oldXHR = $.ajaxSettings.xhr;
$.ajaxSettings.xhr = function () {
var xhr = oldXHR.apply(this, arguments);
if (xhr instanceof window.XMLHttpRequest) {
xhr.addEventListener(‘progress’, this.progress, false);
}

if (xhr.upload) {
xhr.upload.addEventListener(‘progress’, this.progress, false);
}

return xhr;
};
})(jQuery, window);

To use it, you would write code allong the lines of:

Upload: function(data,  callback, progressCallback)
{
var strUrl = “/Upload.aspx”;
$.ajax({
method: ‘POST’,
url: strUrl,
dataType: ‘json’,
data: {
Data: data
},
success: function (result)
{
callback(result);
},
error: function () { },
progress: function (e) {
if (e.lengthComputable) {
progressCallback(Math.round(e.loaded / e.total * 100));
}
}
});
}

I’ve just used this on the upload feature of https://httpsimage.com

Categories: Uncategorized

Make an authenticated #Http Request with #Kotlin

kotlin_250x250

Kotlin is a superscript of Java, and the next big thing in Android programming, so it’s worth taking a little dabble in the language, to do something basic.

Beyond Hello World, I always see if I can use it to call an API, which of course, my example below is of RegCheck.org.uk – a car registration API. You’ll need to get your own username and password at the website to try out the below code.

Create a file called Http.kt as below;

import java.io.IOException
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;

fun main(vararg args: String) {
val response = sendGet(“https://www.regcheck.org.uk/api/json.aspx/Check/LA15ECT”,”**username**”,”**password**”);
println(response);
}

 

private fun sendGet(url: String, username: String, password: String ) : String {
val connection = URL(url).openConnection() as HttpURLConnection
val auth = Base64.getEncoder().encode((username + “:” + password).toByteArray()).toString(Charsets.UTF_8)
connection.addRequestProperty(“Authorization”, “Basic $auth”)
connection.connect();
val text = connection.inputStream.use { it.reader().use { reader -> reader.readText() } }
return text;
}

Compile the JAR using the code;

kotlinc http.kt -include-runtime -d http.jar

Then run it by using;

java -jar http.jar

and you should get the output

“ABICode”:”21057867″,”Description”:”2015 Honda Civic Type R Gt, 1996CC Petrol, 5DR, Manual”,”RegistrationYear”:”2015″,”CarMake”:{“CurrentTextValue”:”Honda”},”CarModel”:{“CurrentTextValue”:”Civic”},”EngineSize”:{“CurrentTextValue”:”1996CC”},”FuelType”:{“CurrentTextValue”:”Petrol”},”MakeDescription”:”Honda”,”ModelDescription”:”Civic”,”Immobiliser”:{“CurrentTextValue”:””},”NumberOfSeats”:{“CurrentTextValue”:4},”IndicativeValue”:{“CurrentTextValue”:””},”DriverSide”:{“CurrentTextValue”:”RHD”},”Transmission”:{“CurrentTextValue”:”Manual”},”NumberOfDoors”:{“CurrentTextValue”:”5″},”ImageUrl”:”http://www.regcheck.org.uk/image.aspx/@SG9uZGEgQ2l2aWM=”,”VehicleInsuranceGroup”:”21″}

Categories: Uncategorized

#Backup #AWS #Route53 DNS Zones in C#

route53

If you host your DNS on Amazon Route53, and it’s reasonably complex, it’s worthwhile taking a backup of it, so that future errors can be undone quickly. There are some tools to do it, however, you can also write a script yourself in C# to do it.

First off, get the NUGET package

Install-Package AWSSDK

Create an IAM user within AWS with programmatic access, and get it’s Access Key and Secret ID. – I’ve given it Administrator access, but you should limit the scope to the minimum.

Then I output all the zones to the console here;

var client = AWSClientFactory.CreateAmazonRoute53Client(“***”, “***”, RegionEndpoint.USEast1);

var strOutput = @”route53backup.json”;

var req = new ListHostedZonesRequest();
for (; ; )
{
var zones = client.ListHostedZones(req);
foreach (HostedZone zone in zones.HostedZones)
{

Console.WriteLine(zone.Name);

var recordSets = client.ListResourceRecordSets(new ListResourceRecordSetsRequest() { HostedZoneId = zone.Id });

foreach (var record in recordSets.ResourceRecordSets)
{
Console.WriteLine(“\t” + record.Name + ” (” + record.Type + “)”);

foreach (var resource in record.ResourceRecords)
{
Console.WriteLine(“\t\t” + resource.Value);

}
}
}
req.Marker = zones.NextMarker;
if (req.Marker == null)
{
break;
}
}

Note that the ListHostedZones call only returns 100 domains at a time, you have to set the “marker” parameter to the value of the NextMarker property that was returned on the previous call to get all records.

 

Categories: Uncategorized

Free HTTPS image hosting – website revamp

Categories: Uncategorized

Access an #Oracle 11g Database via an #iOS app.

Categories: Uncategorized

Connecting to #PostgreSQL via C#

0107.sdt-postgre

As a planned expansion to the Mobile SQL client app (https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1325541368&mt=8) for iOS, – soon support for Oracle and Postgre will be added.

The back-end to the app is some C# middleware, and the code it uses to connect to Postgre is as follows;

private static DataTable ExecutePostgre(string strDataSource, string databaseName, string strUsername, string strPassword, string strSQL)
{
const string strDsnTemplate = @”Server={0};User Id={1}; Password={2};Database={3};”;
var sqlConnection = string.Format(strDsnTemplate, strDataSource, strUsername, strPassword, databaseName);
var adapter = new NpgsqlDataAdapter(strSQL, sqlConnection) { SelectCommand = { CommandTimeout = 0 } };
var dataSet = new DataSet();
adapter.Fill(dataSet, “sql”);
return dataSet.Tables[“sql”];
}

Where NpgsqlDataAdapter comes from the Nuget Package Npgsql, which is installed using

Install-Package Npgsql

Categories: Uncategorized