FileMaker 13 shipped with a new function called GetContainerAttribute(). The function is ostensibly about container fields and their contents. It was designed to let you query the metadata that is often stored along with images; things like geotags, dimensions etc. One the “attributes” that you can get from an image is its MD5 hash. And that’s where things get interesting.
GetContainerAttribute’s Secret – Native FileMaker MD5 Hashes
Although it appears from the function signature, GetContainerAttribute( sourceField ; attribute ), in the case of MD5 it works just fine on a text string. For example:
GetContainerAttribute( "FileMaker 13" ; "MD5" )
What’s a Hash?
I’ll leave the full definition to Wikipedia. But for this post, let’s just say that a hash is a way of taking some data of arbitrary length and getting back some data of shorter fixed length that serves as a unique reference to the original. The “hashed value” can’t be unhashed to get the original value. But the same input will always produce the same output. This is sometimes called a “one-way hash.”
For example the MD5 hash of the above paragraph is “49f752631a812d132505267427550ffb”. If I change one thing in the original and hash it again, I get a completely different value. If I was to capitalize the last word, “output” to “Output”, the hash would be “78d9d4d1be167bef079cfb702ee1cc85”.
Wikipedia lists many uses of Hash functions. I am going to focus on just two, encryption and change detection. Before we go on, I should say that the MD5 Hash has been shown to be weak in terms of encryption, but it is the only encryption function we have in FileMaker, so we will use what we have.
In the video, I demonstrate how to use the GetContainerAttribute function to hash and store user passwords in a FileMaker Database. Although this isn’t recommended, many people do it because it has several advantages over using FileMaker’s built-in account password management. I also cover the use of a “salt” to make the one-way hashing a bit more secure.
As we have seen, a hash is a shorter unique representation of a bigger thing. This makes it useful if you want to check if a big thing has changed from one point in time or another without having to store a complete copy of the original big thing. In the video, I demonstrate how to get a hash of a Filemaker found set of records. In other words, we can get a hash value that represents all the records in a found set. If any record is changed, or if a record deleted or added or hash value will change. It lets us answer the simple question “Did anything about this found set change since the last time I looked.” This could be useful if you needed to do some heavy data processing on a found set, but only if it changed since the last time you did it.