On Servoy 2021.03 the result is: “UHhbewb2lJqSdYa3473xkarw1qtq0o51m2QUEkMFLXI=”
On Servoy 2024.03 the result is: “wAOEKyfUEyNEv/QhIE1HS+k7SrvAXBM3XvNRNbuclwE=”
I get similar results in both versions.
But real question is which version of the svyUtils module are you using in both versions?
For me this is:
v1.6.1 in Servoy 2021.03
v2024.3.0 in Servoy 2024.03
You can find these version if you click on svyUtils module in solution explorer and look at the properties pane.
The bottom property should say ‘version’
v1.6.1 in “Servoy 2021.03”
v2024.3.0 in “Servoy 2024.03”
I’ve found out that it seems to work as long as I just use ASCII-Characters as arguments. But as soon as I have something non ASCII (like for example “é” or “£” (Pound-Sign), the result is completely different!
So it’s really crucial to test it excactly.
scopes.svyCrypto.getSHA256("£"); // results in "tP4VHkE0RTV7HAk1588EpClJLr0j3GK/rbL4mMQxwf0=" (Servoy 2021.3) / results in "bZD7rMBz7gtMQ/OjKRzs2jN2T21m0UIkrWD0cfLIM0s=" (Servoy 2024.3)
I debug through that “getHash”-Function and found a difference in the Byte-Array that is returned by the “string2Bytes”-function. When I have a look at the “string2Bytes”-function in “svyCrypto”, there is a little difference, but more like a clean up of code and not something that really makes any difference. The only thing I could imagine is, that we have Java 11.0.5 for the 2021.03-Servoy and for the 2024.03 it is the built-in Java that is delivered with the developer (in the admin console it says Java 21). In the string2Bytes-function there is only a call “return new java.lang.String(str).getBytes();”. So maybe this has to do with the Java-version? Or a configuration on the Servoy-Admin-Page that I’m not aware?
return new java.lang.String(str).getBytes('UTF-8');
This is it. If I change it like this in the 2021-developer than I get the same byte-array (and as a result the same hash). Or if I change in the 2024-developer to "return new java.lang.String(str).getBytes(‘cp1252’); then I get also the same hash in both developers (but of course a different one than the ‘UTF-8’-version).
So, obiously somehow the default encoding changed from one developer to the other. But I’ve only found some settings under “Preferences” => “General” (‘Workspace’, but this is for both devlopers already on “other: UTF-8” and then some entries under “Content Types”. I’m not sure which one is relevant for that.
But I remember that when I’ve upgraded from 2021.03 to 2024.03 that there were some new setting-files like “svyBase/.settings/org.eclipse.core.resources.prefs” that have stuff like “encoding/=UTF-8” in there and I’ve wondered what these file are. Maybe these files has something to do with it.
At least I see a solution for my problem, even if I’m a littlebit uncertain what the right fix for this is. Obiously Marc already has the right settings for that because he has the right hashes from beginning. So there seems to be a solution without to adjust the code in “svyCrypto”!
Thanks a lot to Marc and Patrick for your efforts! That really helped me a lot.