

dormky
Members-
Content Count
150 -
Joined
-
Last visited
Everything posted by dormky
-
What is the algorithm used to derive the key to a TMyEncryptor ?
dormky replied to dormky's topic in Databases
There is nothing added to the encrypted data. No IV, no hash, no guid, and I know this because like I said, the output is extremely small and physically cannot contain enough data. Just the letter A gives me one or 2 bytes as a result. Here is some code to reproduce : program Project; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Hash, Data.DB, CREncryption, MyAccess; var conn: TMyConnection; table1, table2: TMyTable; keyBytes, sha1, md5: TBytes; query: TMyQuery; begin SetLength(keyBytes, 36); sha1 := THashSHA1.GetHashBytes('pass'); md5 := THashMD5.GetHashBytes('pass'); Move(sha1[0], keyBytes[0], 20); Move(md5[0], keyBytes[20], 16); conn := TMyConnection.Create(nil); conn.Port := 3306; conn.Username := 'root'; conn.Password := 'toor'; conn.Server := 'localhost'; conn.Connected := True; conn.ExecSQL('DROP DATABASE IF EXISTS encryptor_test;'); conn.ExecSQL('CREATE DATABASE encryptor_test;'); conn.ExecSQL('USE encryptor_test;'); conn.ExecSQL('CREATE TABLE test_data (`Name` varchar(255));'); table1 := TMyTable.Create(nil); table1.Connection := conn; table1.TableName := 'test_data'; table1.FieldDefs.Add('Name', ftString, 250); table1.Encryption.Encryptor := TMyEncryptor.Create(nil); table1.Encryption.Encryptor.DataHeader := ehNone; table1.Encryption.Encryptor.Password := 'pass'; table1.Encryption.Fields := 'Name'; table1.Active := True; table1.Insert(); table1.FieldByName('Name').Value := 'A'; table1.Post(); table2 := TMyTable.Create(nil); table2.Connection := conn; table2.TableName := 'test_data'; table2.FieldDefs.Add('Name', ftString, 250); table2.Encryption.Encryptor := TMyEncryptor.Create(nil); table2.Encryption.Encryptor.DataHeader := ehNone; table2.Encryption.Encryptor.SetKey(keyBytes, 36); table2.Encryption.Fields := 'Name'; table2.Active := True; table2.Insert(); table2.FieldByName('Name').Value := 'A'; table2.Post(); end. Strangely enough when using password the output does not change : E2. When using SetKey, the result varies so I suppose the IV is directly derived from the password. I'm getting a single byte here as output instead of 2 in the full project though, which is strange. Edit : Signing of for the day, have a nice weekend ! -
What is the algorithm used to derive the key to a TMyEncryptor ?
dormky replied to dormky's topic in Databases
The IV and other metadata cannot be contained in the data. I just tried with just the letter 'A' and the output is always the same 2 bytes. Therefore, the IV is a hardcoded value somewhere. Could you share this ? -
What is the algorithm used to derive the key to a TMyEncryptor ?
dormky replied to dormky's topic in Databases
I don't get what you mean by "magic number", and your way of writing makes it very hard to understand what you mean 😕 If you can't provide the algorithm used that's fine I understand. I really don't get how you can encrypt with blowfish without padding, since blowfish uses 8-bytes blocks. Is the padding simply ignored with the length is known ? When I try to pass data that is not a multiple of 8 bytes, python's cryptography package raises an error. Also my encrypted test data is only 8 bytes (4 characters), I'm not using tag and hash. And all this is irrelevant as long as I don't have the algorithm that derives the key from the password, it's the only thing I need. -
What is the algorithm used to derive the key to a TMyEncryptor ?
dormky replied to dormky's topic in Databases
> hence removing the need for padding That cannot be correct, Blowfish (the default algorithm which I am using here) requires padding ? The security of the encryption is not my problem here, the problem is that I cannot read the data using anything other then a Devart product. The data is already encrypted so nothing about the algorithm can be changed, I need to use the exact same process. I've tried to recreate the same process in python with PKCS7 padding but I don't get the same result. -
Best way to store and compare PC configuration data
dormky replied to Shrinavat's topic in Algorithms, Data Structures and Class Design
Doing a file-based comparison will always lead you into problems where something changes, but it's not something that actually impact the configuration in real-life. Better to write code to handle the comparison. If you really don't want to do that, you need empty spaces ie reserve 30 lines for drives and when saving, always sort alphabetically. Each field would have a specific length so no offset changes. But it's going to be a pain. Maybe separate the data you actually want to compare ; even in a single file you can have a marker like a line of '|' after which the data resides and you have a very small script to compare that part of the file and not the rest. -
What is the algorithm used to derive the key to a TMyEncryptor ?
dormky replied to dormky's topic in Databases
Just occurred to me that I won't know how they're padding the content... So yeah. -
What is the algorithm used to derive the key to a TMyEncryptor ?
dormky replied to dormky's topic in Databases
Okay I'm not sure I understand what you're saying but 1) You have the source-providing license 2) In the source you can see the Password2Key function concats the the SHA1 and MD5 of the password to generate the key ? I suppose it's still like this because TMyEncryptor just inherits from TCREncryptor and doesn't actually add anything from what I can see. Probably they wanted it named with a "My". I'll try a python script to reproduce the encryption and see if SHA1+MD5 lands me on the same results. Thanks. -
Done using https://www.onlinegdb.com/online_pascal_compiler, but Delphi 10.3 does the same. What the fork ?
-
The documentation is utterly unhelpful, I've done the 3 steps outlined here : https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Creating_a_New_Component After those three steps, it says "Now you will have a minimally functional component ready to install on the Tool Palette. After installing [...]". But there is no step explaining how to install !
-
I feel like my time and the stability of the application will be much better served if I simply makes a class that takes my base component as a parameter. It's to draw on a bitmap anyway so not much going on at design time. Thanks anyway, at least I know not to refer to the docs on this subject 🙂
-
Claude has multiple advantages for me : - You can give it a large amount of info (I've been pasting entire units into it) - Moderately better at Delphi (ie not making too much stuff up) - Won't give you entire paragraphs explaining why 1+1=2, it's way more concise and won't re-explain everything with every answer, mostly just show the code change. Not sure if this is a measure to not consume as much but it's great for since I always have to bang ChatGPT's head about giving only-code answers.
-
When my DBGrid's datasource points to a TMyTable, its fixed rows are drawn like this : But when changing to a TClientDataSet, they are drawn like this : What can I do to prevent this change ? Is this a style problem ? Is it a difference in settings between the TClientDataSet and the TMyTable ? I haven't found one that could provoke this but it's the best idea I've got as to why this behavior occurs.
-
(These are TBitBtns) In the first image, all buttons are enabled. In the second, the bottom two are disabled. It seems that the disabling makes every color except for pure black completely disappear (see the grey at the top of the pencil disappeared too). What can I do to prevent this ? The icon should just be greyed out, not entirely disappear. I don't want to make greyed out glyphs and switch them around for literally every button in the program either. Although if it comes down to it, I guess I could always have a custom button that takes the existing glyph and greys it ? But that sounds finicky and there's probably a better way of solving this. Thanks !
-
A search for TBitBtn just gave me 1842 results, and that's just the "main" part of the program. Now not all of these buttons have icons of course, but a significant portion does. We're talking at least hundreds of buttons to update and check here. So no it's not every icon, but it's still a whole freaking lot.
-
Those lines were literally written before I was born. Believe me if I could throw it all away I would but alas that's not realistic. Try to explain to management why we'd need so much time and testing to "make the icons grey" :')
-
It is a shame that TBitBtn's method of greying out an icon is to make black grey, and every other color white. That is not a good method imo as it leads to problems like this in this post, forcing the developer to put in more work (re-implementing the greying or creating greyed out icons). A UI framework should have correct greying, that's not something up for debate.
-
Yes, but doing this for every icon in this 1M lines project does not make sense if there is another solution out there. Especially as greyed out an existing image is not complicated in itself, it's just the implementation in TBitBtn that's faulty.
-
Such a shame. It seems the Images property only exists for TButton. I've tried adding my bitmap to the property but it doesn't seem to work like the Glyph property (double click to edit). How am I supposed to add it ?
-
Actual insanity.
-
How come .dcu files aren't the same across builds ?
dormky posted a topic in RTL and Delphi Object Pascal
When I build .dcu files, they often aren't the same size. Does anyone know why that is ? I literally just build two times in a row, and between 5 and 10% of .dcu will have a size difference of a few dozen bytes. I'm trying to apply formatting to the whole project and want to verify that the output is not affected (trust but verify, heh ?) but if building the same thing twice already leads to significant changes this will be quite difficult to achieve... And yes, we have 0 test coverage. Edit : Example with this small file, where 4 bytes are added at around 3/4ths of the file. UConfigEchelle_big.dcu UConfigEchelle_small.dcu -
How come .dcu files aren't the same across builds ?
dormky replied to dormky's topic in RTL and Delphi Object Pascal
Ah, it might be the debug info indeed for the big changes when formatting. But there's still differences when compiling 2 times in a row, which I can't explain (see attached files in the OP) -
How come .dcu files aren't the same across builds ?
dormky replied to dormky's topic in RTL and Delphi Object Pascal
Well, I just checked on the effects of formatting on .dcu files and they seem to be affected a lot. Very strange that intermediate compiler files would be affected by formatting. Does delphi output other intermediate files that I could check ? -
I'd like to extract a row's data as an object from a TMyQuery, so that I can give it as an argument to a function. But I don't see anything that can achieve that in the doc. For background, this is using MyAccess to grab from a MySQL DB. Typically I'd like to have something like MyQuery.First(); DataObject := MyQuery.CurrentData(); MyQuery.Next(); // DataObject still has the data from the previous row
-
How can I extract a row's data from a TMyQuery object ?
dormky replied to dormky's topic in Databases
DataSetHelper does indeed seem to be what I'm looking for ! Too bad I'm almost finished writing the RTTI solution described just above by Lars, which I suppose is what DataSetHelper is doing. Writing it myself was what i wanted to avoid, but alas. Since I've written tests for it I'll use my code, but thanks for coming though anyway 🙂 -
I'd like to create a TValue that holds a TBytes array. From what I see of TValue's code, it doesn't seem to be designed for such, even by using variants. Alternatively, if I can just get a pointer to the relevant instance field from TRttiField and cast it to a TBytes, that'll work too.