Tuesday, 21 January 2020

Password Hashing

Delphi is great for all kinds of software development from Windows based applications to web sites and mobile apps, but one area that it seems to be weak is with hashing of passwords. I cannot find any components built in or 3rd party that really do what was easy to do with Visual Studio (C#), here is what I would like to do:

  1. Find a modern hashing algorithm PKBDF2 or Argon2. 
  2. Must allow hash to be salted and the salt to be different every-time.
  3. Allow for the number of iterations to be specified.
  4. Previously I have also store a version number with the hash, this would also be a useful option.
  5. Validation should not require the original salt. Some solutions (one well known 3rd party company) says that you store the hash of the password and the salt in the database. 
  6. Works with existing Javascript hashing solutions e.g. CryptoJS, I imagine once the same parameters are applied it should work so that the hash can be created in Javascript and the validation can be done by Delphi.
Does anyone no of any 3rd party components that do password hashing well?

Thursday, 17 October 2019

Will the generic TObjectList bug with serialising to JSON get fixed?

When I try to serialise a generic TObjectList to JSON doing something like this:

Response.Content  := TJSON.ObjectToJsonString(MyObjectList);

I get the error Type tkPointer is not currently supported. I am using 10.3 and I believe this bug (21685) has been around since XE8. I am currently having to think of workarounds and trying to find the best solution. It would be really useful if they would fix this bug, or give some idea of when it will be fixed, does anyone know?

Tuesday, 20 August 2019

What are the Delphi alternatives to RAD Server for REST?

I am looking at the best solution for a REST service in Delphi (Berlin or Rio) and all the tutorials and examples I have come across use RAD Server, which is part of the Enterprise version and not in the Professional version, which is the version I am using. One possible alternative to RAD Server is to use 3rd party components like Habari. Does anyone have any advice on alternatives or is RAD Server the best option for RESTful services in Delphi? 

Monday, 22 July 2019

ClientDataSet SaveToFile writes the field values in reverse order

I have noticed that when I have a TClientDataSet with a single record and I use 'SaveToFile' to save the values to an XML files the order of the fields in the XML is in reverse order. For example if you have the following in the TClientDataSet:

TableID
Name
Address

When this is saved to an XML file the meta data is in the correct order, but the values for the fields in the XML is in reverse order.

Address
Name
TableID

I wonder if this is done by design.

The version of Delphi I am using is Tokyo.

Friday, 14 September 2018

Does Delphi have a future?

I've been using Delphi for almost 20 years now, I have worked in various industries and have also used other languages and IDEs like C#, Xcode, VB.Net, but while developing in other languages I have always been doing something with Delphi and I am a big fan of it. There are many reasons why I enjoy and have a preference to develop some applications in Delphi, but recently I have one problem with it.

The problem I have with Delphi is its future and the question that gets raised 'how easy is it to employ new developers?'. In the UK it is almost impossible to employ a good Delphi developer and can take years to find one. The other option is to employ a developer with good OOP skills and knowledge of a similar language like C# and for them to learn the language (currently no Pluralsight courses). The problem with employing a developer who does not know Delphi is they do not want to learn Delphi, it is not a big enough carrot on the stick and salaries in the UK are less than other languages.

What I would like to know are the selling points of Delphi to a young person who knows OOP and has some experience in software development. I asked myself the question, 'if I was young and needed to choose a language and development environment, would I invest my future in Delphi?' The short and current answer is 'No'.

Thursday, 28 June 2018

Delphi features that I was not aware of

The other day I came across a feature of Delphi that in my 18+ years of using Delphi have never used, it is the 'Hide Non-Visual Components' (Ctrl+H) when design a form. I came across this because another Developer pointed out to me that he could not see the menu controls on a form. I thought there might be an option somewhere and on the right click menu was the option.

I have never used this feature and it got me thinking what other features are there that I am not aware of (Delphi Berlin) and are there any that I might use. Here are 2 lists of features I have since discovered, one list is for ones that I think are pointless and I would never use and the other for features that I believe are useful.

Features I've found that I think I will never use:
  1. Quick Icon - right click menu option in the form designer.
  2. Quick Edit - right click menu option in the form designer.
  3. Flip Children - right click menu option in the form designer. I think I'v seen this before, but have never used it and cannot think of when I would.
  4. Lock Controls - main menu > edit. This feature locks some controls on forms from resizing and moving. This feature has strange behaviour as it sometimes locks the resize, but not the ability to move the control, try locking the controls, closing the form and opening it again and the size of the controls cannot be changed but the positions can. Clearly never been through QA.
  5. Scale - main menu option > edit. This gives the developer the feature to scale a form and it's controls be a percentage. 

Features I've found that could be useful:
  1. Surround > Region - right click menu option in the code editor. 
  2. Search for Usages - right click menu option in the code editor.  
This is just a brief list of features that I have found over the last couple of day that I was not aware of, most of which I will never use. There are most likely other features in Delphi I have yet to discover that are of some use. 

Tuesday, 19 June 2018

Why does TSpinEdit not enforce the MaxValue property?

With a TSpinEdit there is a property called 'MaxValue', from the name it implies that the maximum value for the control is what value you set for the property, but this is not the case. The property sets the maximum value for using the spin edit buttons, a user can enter a value exceeding the maximum value by using the keyboard up to the value of an Int64 (9,223,372,036,854,775,807).

This seems to have been done by design, but I cannot see a valid reason for this and it could be a little dangerous when being used to control the valid values entered.  

By putting the following in the OnChange event I've managed to get around the problem. Not sure if there is a better solution. 

if (Sender is TSpinEdit) then
begin
    if (Sender as TSpinEdit).Value > (Sender as TSpinEdit).MaxValue then
    begin
        (Sender as TSpinEdit).Value := (Sender as TSpinEdit).MaxValue;
    end;
end;