Blogs from Jim McKeeth - Embarcadero Communityhttps://community.embarcadero.com/blogs/blogger/listings/jimmckeeth
Thu, 24 May 2018 13:42:53 -0700Joomla! - Open Source Content Managementen-gbSHA Hash with C++Builder and Delphihttps://community.embarcadero.com/blogs/entry/sha-hash-with-c-builder-and-delphi
https://community.embarcadero.com/blogs/entry/sha-hash-with-c-builder-and-delphiI've always been fascinated by encryption & compression, but my favorite is probably the cryptographic hash function. A hash function is a one-way algorithm that takes an input of any size and always produces the same size output. It is one-way in that there is information loss -- you can't easily go from the output to the input again. The cryptographic hash is a more secure version of the hash function. It is most often used in signing to validate that data hasn't been modified.

Per Wikipedia, the ideal cryptographic hash function has five main properties:

it is deterministic so the same message always results in the same hash

it is quick to compute the hash value for any given message

it is infeasible to generate a message from its hash value except by trying all possible messages

a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value

it is infeasible to find two different messages with the same hash value

The Message Digest family of cryptographic hashes used to be the main players in the area, but they were found to be insecure. Now SHA family rules as the main workhorse of modern cryptography.

The basis of hash support first appeared in the RTL around the 2009 release but in XE8 (2015) we got the System.Hash unit, which brought the MD5, SHA-1, and Bob Jenkins hashes. Then in 10.0 Seattle (2015) it was expanded with SHA-2 support. Most recently in 10.2 Tokyo (2017) the hash functions were expanded to accept either a string or stream in addition to the original bytes input.

The SHA Family includes SHA-0, SHA-1, SHA-2, & SHA-3 family of hashes. SHA-0 is obsolete, and SHA-3 is an improvement on SHA-2. In practice I see most hashes using either SHA-1 or SHA-2. SHA-1 always produces a 160-bit (20-byte) hash (digest), while SHA-2 includes 224, 256, 384, and 512-bit outputs, making it both more secure and more flexible. SHA 256 & 512 represent 32 and 64-bit word size hash algorithms. The 224, 256, & 384 size digests are truncated versions of the 256 & 512 algorithms.

So how do you use it in C++Builder and Delphi? I'm glad you asked. Once you have included the System.Hash unit then you can use the methods of the THashSHA2 class to create the digest. I'll show you how to use GetHashString, but know there are other variations you can use too. The GetHashString takes either a string or a stream and returns a hexadecimal string of the hash.

I made a little sample app that generates all the different hashes from the text you provide. It is a FireMonkey app, so will work on all the platforms, but the hash code will work in any type of app. There are both C++ and Delphi versions included.

This is a pretty simple 3D form with a 3D layout at an angle, and then a 2D layout with text and images is animated up the 3D layout. The only code is populating the labels as the animation kicks off automatically.

Download the code and run the full credit scroll, or change the message to share with your friends. It is FireMonkey, and while I only tested it on Windows, it should work on Android, iOS, macOS, and even Linux if you are running FMX Linux.

Read more]]>jim.mckeeth@embarcadero.com (Jim McKeeth)BlogsFri, 04 May 2018 17:46:56 -0700Webinar Replay: Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBasehttps://community.embarcadero.com/blogs/entry/embeddable-databases-for-mobile-apps-stress-free-solutions-with-interbase
https://community.embarcadero.com/blogs/entry/embeddable-databases-for-mobile-apps-stress-free-solutions-with-interbaseWhen it comes to developing mobile applications, keeping data on your device is a must-have feature, but can still be risky. With embedded InterBase, you can deploy high-performance multi-device applications that maintain 256-bit encryption, have a small footprint and need little, if any, administration.

What can participants expect to learn: Using InterBase in your mobile apps is easier than you may expect. Learn to develop mobile applications using InterBase, and how to take advantage of some of the convenient features about InterBase like Change Views and 256-bit security.

So the private IP is different from the public IP. I’ll need to test to see if it is mapped with NAT or something. Seems unlikely though. Google offers public facing computers as part of their cloud services, so it makes sense that you would use those instead.

322.69 Mbit/s down and 260.94 Mbit/s up is really impressive! So if you have a task that requires a lot of bandwidth and then condenses it down to a smaller digest, it would be a really useful platform.

Read more]]>jim.mckeeth@embarcadero.com (Jim McKeeth)BlogsWed, 14 Mar 2018 19:53:22 -0700Fix for Google Play Services Dex error in 10.2.3https://community.embarcadero.com/blogs/entry/fix-for-google-play-services-dex-error-in-10-2-3
https://community.embarcadero.com/blogs/entry/fix-for-google-play-services-dex-error-in-10-2-3If you installed 10.2.3 over 10.2.2 you may see an error similar to the one found below relating to dex and google-play-services.dex.jar when targeting Android. There were some changes in 10.2.3 to update it to use AdMob SDK version 7, and there is a workaround on the DocWiki page for migrating existing apps to 10.2.3. You can use that workaround for your new projects, or if you installed 10.2.3 over 10.2.x then there may be some files you need to clean up . . .

If you go to C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\debug (see picture above) you will find that two of these jar/dex files are not like the others. With a date from December of 2017, while the rest are dated for March of 2018. They are left behind from 10.2.2 and the earlier version of AdMob. The suspect jar/dex files are found in both the lib\android\debug and lib\android\release folders. Delete them from both locations:

Delete the following files (or remove and back them up if you are the paranoid cautious type)

com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:198) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:506) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:336) at com.android.dx.command.dexer.Main.runDx(Main.java:291) at com.android.dx.command.dexer.Main.main(Main.java:247) at com.android.dx.command.Main.main(Main.java:94)

Read more]]>jim.mckeeth@embarcadero.com (Jim McKeeth)BlogsFri, 09 Mar 2018 14:16:19 -0800Asking Questions to Get Answershttps://community.embarcadero.com/blogs/entry/asking-questions-to-get-answers
https://community.embarcadero.com/blogs/entry/asking-questions-to-get-answersAsking development and troubleshooting questions is a mix of art and science. Sites like Stack Overflow and other developer community forums will often reject questions that do not meet their standards. Even when you are sending a support request to our premium update subscription support you can save a lot of time by providing all the necessary information in your first message. There are a few guides to asking questions that get answers, so I thought I would combine the best tips from them here in a useful reference (see the list of sources at the end).

One of the themes I’ve seen in a lot of these guides is that many times in the process of asking a well-researched question you will discover the answer on your own. This is the ideal solution as I believe you learn the most in this situation. More than once I’ve posted the answer to my question immediately after asking it for this very reason. One tip to do this is called Rubber Duck Problem Solving which even has a Wikipedia page describing it. If you have an IDERA Rubber Duck handy you can put it to work for you!

Here are my tips for asking good questions to get good answers:

Be Specific - What are you trying to accomplish specifically? Or what were you expecting to happen? Just saying something doesn’t work, or asking for an example of FireDAC isn’t really enough to go off of. Also be specific about what version you are using, target operating system, 3rd party components, etc.

Use a Descriptive Title or Subject Line - Especially when posting on peer-support, people are scanning the list of questions to see what they feel comfortable answering. If you have a good title they are more likely to click on it to answer it. But if your title is vague then they probably won’t bother.

What Have you Tried? You don’t want the first few answers to be things you’ve already tried in troubleshooting the issue. And if you haven’t tried anything then you should do that first (a little research saves you a lot of work).

Include the Minimal Code - Create the simplest possible program that demonstrates the problem or what you are trying to do. Don’t include the DCU or anything that isn’t necessary. Often times the process of creating a small app that reproduces the issue you discover the cause of it.

Include Links - Likewise, if there is a link to the documentation that describes what you are trying to do that can help too. This goes with the What Have you Tried part too. You don’t want the first response to be a link to the page you just finished reading.

Include the Errors - If you are getting an error include the exact error. The full text of the error and not just a screenshot. If the screenshot ads something you can include it too.

Is it reproducible? What are the dependencies? If possible try reproducing it on a different version or different install. Maybe disable any IDE plugins or turn runtime packages off. Does debug vs. release make a difference? Have you tried it with your virus scanner disabled?

I’d also add one more tip to be sure and post to the correct place. Here are a few places you might find answers

Embarcadero Community is a good place for peer support for questions specific to our products.

If you are using a 3rd party component check to see if they have their own support forums or channels.

Use the Quality Portal if you are reporting an actual bug or making a feature request.

Stack Overflow is a good venue to get answers, especially if they involve broader technology like consuming the Facebook API.