TurboMagic 92 Posted July 27, 2021 In order to test something, I'd need to have the Hash_Console Demo console application from https://github.com/MHumm/DelphiEncryptionCompendium (DEC) translated to C++ Builder. Why do I need this? In DECOptions.inc there are some switches which would enable 32 bit asm optimized variants of some hash algorithms. The previous developers left a comment there that those are commented out due to some C++ Builder issue. Now if I could check whether this issue still persists and if yes, whether I can selectively disable them via some define, I could improve the library's performance at least for Delphi users and if the issue no longer persists maybe even for C++ Builder users. Share this post Link to post
David Heffernan 2353 Posted July 27, 2021 What pay rate are you offering? Share this post Link to post
Remy Lebeau 1436 Posted July 27, 2021 A straight C++ translation of the Hash_Console demo would look something like this: /****************************************************************************** The DEC team (see file NOTICE.txt) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of this licence is found in the root directory of this project in the file LICENCE.txt or alternatively at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ******************************************************************************/ /// <summary> /// Most simple demonstration of DEC hash routines /// </summary> #include <vcl.h> #pragma hdrstop #include <System.SysUtils.hpp> #include <DECFormat.hpp> #include <DECHash.hpp> #include <iostream> #include <limits> int main() { THash_RipeMD160* Hash = new THash_RipeMD160; try { try { // Calculate a hash value in accordance to the original author's test data // http://homes.esat.kuleuven.be/~bosselae/ripemd160.html RawByteString s = "message digest"; std::cout << "RipeMD160 digest (hash value) of " << s.c_str() << " is \n" << Hash->CalcString(s, __classid(TFormat_HEX)).c_str() << std::endl; std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); THash_Whirlpool1* W = new THash_Whirlpool1; s = "The quick brown fox jumps over the lazy dog"; std::cout << "RipeMD160 digest (hash value) of " << s.c_str() << " is \n" << W->CalcString(s, __classid(TFormat_HEX)).c_str() << std::endl; delete W; std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } catch(const Exception &E) { std::wcout << const_cast<Exception&>(E).ClassName().c_str() << _D(": ") << E.Message.c_str(); } } __finally { delete Hash; } } 1 Share this post Link to post
Fr0sT.Brutal 900 Posted July 28, 2021 10 hours ago, David Heffernan said: What pay rate are you offering? Quite rude David, he's doing opensource Share this post Link to post
TurboMagic 92 Posted July 28, 2021 Ok, thanks for this rough translation Remy! Now I simply need to get some DECFormat.hpp and DECHash.hpp. Is there a way to get them generated or do I need to craft/create them manually? Share this post Link to post
David Heffernan 2353 Posted July 28, 2021 11 hours ago, Fr0sT.Brutal said: Quite rude David, he's doing opensource "I need to have XXX translated to YYY" seems a little abrupt to me. Share this post Link to post
TurboMagic 92 Posted July 28, 2021 Sorry, David, but I do not speak "C" much and as the DEC library I'm working on seems to be mostly C++ Builder compatible I didn't want to ruin that compatibility just to have some speed gains on Delphi side. The simple solution would have been to remove the uncommenting and don't care about C++ Builder. Share this post Link to post
Remy Lebeau 1436 Posted July 28, 2021 1 hour ago, TurboMagic said: Now I simply need to get some DECFormat.hpp and DECHash.hpp. Is there a way to get them generated or do I need to craft/create them manually? .hpp files are auto-generated by the Delphi compiler when run with the -JL or -JPHNE switch. See Creating C++ Files from DCC32 Share this post Link to post
TurboMagic 92 Posted July 28, 2021 Thanks! I'll try to find the required time in the next few days. Share this post Link to post
TurboMagic 92 Posted July 30, 2021 I just tried. I got the .hpp files and copied those two referenced over into the directory of that project, but compilation gives a [ilink32 failure] Fatal: file 'SYSTEM.CLASSES.OBJ' cannot get opened. I tried to find the file in my VM, but I failed. Share this post Link to post
Remy Lebeau 1436 Posted August 2, 2021 On 7/30/2021 at 11:11 AM, TurboMagic said: I just tried. I got the .hpp files and copied those two referenced over into the directory of that project, but compilation gives a [ilink32 failure] Fatal: file 'SYSTEM.CLASSES.OBJ' cannot get opened. I tried to find the file in my VM, but I failed. It is not enough to just use the .hpp files, you have to link to the RTL library as well. You are not finding SYSTEM.CLASSES.OBJ because is not actually a standalone file that exists anywhere. System.Classes is a unit that exists inside of the RTL. So make sure you are linking against rtl.dcp, IIRC. The easiest way to go is to just start with a newly created VCL-enabled console project and then add the translated C++ code into it as needed. Share this post Link to post