Generating the encryption key with AL

dreezdreez Member Posts: 72
Hello,

how can I generate 256 bits sized encryption key with AL code? I need this for AES encryption.

Answers

  • ftorneroftornero Member Posts: 524
    Hello @dreez

    You can take a look to this post:

    https://forum.mibuso.com/discussion/comment/332698#Comment_332698

    Regards
  • dreezdreez Member Posts: 72
    edited 2021-09-04
    Hey, @ftornero.

    Thank you for your reply. I know what AES256 (Rijndael) algorithm is. I just need to generate a random encryption key (which is clave in your app). You have to remember that in AES256 you have to use 256 bits (32 bytes) sized key and I need to generate it randomly. Rijndael provider codeunit has got "GenerateKey()" and "GenerateIV()" functions, but it is not enough for me, I would prefer to Generate the key before the initialization of the RijndaelProvider class and also I just need to know the value of the key, I just need to make it random each time for safe issues.

    Do you know any way to generate proper (128, 192 or 256 bits length) random encryption key (or as you called it - Clave) in AL? I just don't want to write my own solution if there might be something already implemented, like in any other programming language.
  • ftorneroftornero Member Posts: 524
    Hello @dreez,

    In this case maybe you could create a GUID and get the part that you need to get a 128, 192 or 256 key.

    Regards.
  • dreezdreez Member Posts: 72
    edited 2021-09-04
    GUIDs aren't cryptographically secure, because they follow predictable pattern.
    I will figure something out, if there are no already implemented solutions, thanks ;)
Sign In or Register to comment.