Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.Net implemenation of AES
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01682347
Message ID:
01682371
Views:
60
You can specify the keysize in AES and that determines the size of the key.

See here:

https://dzone.com/articles/encryption-and-decryption-in-cnet-aes-and-des-encr

256 bit keys are 32 bytes which is what SHA256 hashing should give you to get your AES256 (which isn't a thing as I mentioned). 128 bits is a 16 bytes key. The hash algo will determine the size of the key as Gregory pointed out as the hashes produce fixed length binary values.

I'm no expert on encryption either - this stuff confuses the heck out of me, and I basically provide the wrappers and make sure that they produce the correct output by testing against known examples. I know that given the right inputs you can generate the proper results for these algorithms using wwEncryption, which is a wrapper around these functions.

If you want more control - create a .NET assembly use .NET code to write, debug and test it, and then call it from FoxPro using wwDotnetBridge. The interface to FoxPro can then just be a very simple function that takes a value and key and the rest is hidden away.

wwEncryption as a generic tool using single use functions is always more cryptic (especially using AES which requires IV and Hash Algo) given that it has to overload for a bunch of different scenarios where the specific case can use the exact properties on the underlying AES object directly with a handful of lines of code.

+++ Rick ---

>For this implementation, I am using keys of about 54-55 characters. But in the .net class, this must then be hashed to get a standard size and then the hash must be used for the actual encryption key.
>
>I can pass in hashing algo as MD5 or SHA1 or SHA256 as part of the call (via the bridge class) but those yield hashes of 24, 28 or 44 bytes each (192, 244,352 bits respectively). So none of them would yield 128 or 256 bit keys.
>
>In other words, not sure how the .net class uses different key lengths that are passed.
>
>Albert
>
>>
>>AES is a subset of Rijndael where the blocksize is limited to 16 bytes ( or 128 bits)
>>What you see is the keySize in bits: 128, 192 or 256
>>
>>So, when .Net says AES, the only thing you know is that the block size is 16 bytes. The key size depends on how the class is used
>>
>>Further reading https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform