RSA 2048, Blowfish, Rijndael, Whirlpool PureLib
I would like to see an example of string encryption in memory myself, using AES (dont know if thats possible). I don't understand the AES stuff at all. Anyone got any examples of string encryption in memory with AES, or any examples of string encryption in memory with these libraries (if its even possible)?
I don't know if it helps, but I managed to wrap an AES lib in PureBasic. You can find the example inside. The main advantage is that the source is open so it can be tweaked for your needs.
Here's the code
File:1->AES.zip

The thing is that it may contain bugs,etc. but in my test it worked pretty well
.
Here's the code
File:1->AES.zip

The thing is that it may contain bugs,etc. but in my test it worked pretty well

None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Hi Inf0Byt3.
Thanks for you lib.
Works fine for me.
But I have one question left:
In your example, you decrypt a string you crypted before. To decrypt, you need the "neededlength" witch was calculated befor crypting the string.
If you just want (or later want) to decrypt a AES-crypted string, you didnt crypt, you dont know the "neededlength". How can I solve this? Or does calculating-routine work for decrypting too? How can I get this value without knowing it from crypting before?
Thanks for you lib.
Works fine for me.
But I have one question left:
In your example, you decrypt a string you crypted before. To decrypt, you need the "neededlength" witch was calculated befor crypting the string.
If you just want (or later want) to decrypt a AES-crypted string, you didnt crypt, you dont know the "neededlength". How can I solve this? Or does calculating-routine work for decrypting too? How can I get this value without knowing it from crypting before?
Agent_Sasori
Maybe it is easier to understand if I copy the code:
In your AES.pbi you show an example using
My question is:
How can I know the "neededlength" if I did not crypt the text?
In your AES.pbi you show an example using
Code: Select all
AESDecrypt(@out,@dec,neededlength,"testpasasdfsdfasfasdfasdfs",#PureAES_CypherMode_256)
How can I know the "neededlength" if I did not crypt the text?
Agent_Sasori
Hm....
But if you have a AES256 crypted file. Generated by anyone. How will you decrypt it without knowing the length?
For my work I can solve this by saving the length for any crypted string or setting the length to a virtual value like 1024 (the max lenght I would crypt
) This works fine too, but it is not very professional.
But if you have a AES256 crypted file. Generated by anyone. How will you decrypt it without knowing the length?
For my work I can solve this by saving the length for any crypted string or setting the length to a virtual value like 1024 (the max lenght I would crypt

Agent_Sasori
I understand what you're saying, but almost all the programs that crypt files must have a structure inside. If you want to decrypt a file created by another program it's better that you find the way the file was encrypted, it's header. One developer could use for example:
Signature: 4 bytes
Data: n bytes
Data length: 4 bytes (a long)
Then to read it, you go to Lof()-4 , read the data length, go to offset 4 , read n bytes then decrypt. This varies in function to what the developer chose to encrypt and how. I don't know if there's a "magic" method to decrypt files just by opening them. The length must be stored somewhere inside.
Signature: 4 bytes
Data: n bytes
Data length: 4 bytes (a long)
Then to read it, you go to Lof()-4 , read the data length, go to offset 4 , read n bytes then decrypt. This varies in function to what the developer chose to encrypt and how. I don't know if there's a "magic" method to decrypt files just by opening them. The length must be stored somewhere inside.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
First let me say thank you very much for this. I had to search quite a while to find something wich can encrypt memory of any size while giving the option to set a Key/Password for decryption. I first looked at DES but the input can only be 8 chars long so AES is the way to go for me.
My question is about the memory alignment procedure:
Why is it 16? I was asuming the input would be quad alinged so it should be 8, shouldn't it?
As a side note, if you change 16 to the size of quad the length will be the same.
My question is about the memory alignment procedure:
Code: Select all
Procedure Calculate_AES_Padding(*Buffer,Length)
;! http://www.purebasic.fr/english/viewtopic.php?p=66818#66818 !
bytes_remaining.l = Length % 16
padding.l = 16 - bytes_remaining
length_required.l = Length + padding
ProcedureReturn length_required
EndProcedure
As a side note, if you change 16 to the size of quad the length will be the same.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Hi,
That's not my procudure there but I think I know why 16 was used:
That's not my procudure there but I think I know why 16 was used:
AES uses blocks of 16 bytes. That function calculates how many bytes are needed to make a full 16 byte block so the data will be encrypted without errors. There are many methods of padding, one of them with zero, one with spaces, etc.AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits...
Since in computing 1 byte equals 8 bits, the fixed block size of 128 bits is normally 128 / 8 = 16 bytes. AES operates on a 4×4 array of bytes, termed the state (versions of Rijndael with a larger block size have additional columns in the state). Most AES calculations are done in a special finite field.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany