0

I have a generateKey function which was made static and private but I kept on getting error as title. Below is the Inner exception explanation as per exception.

using java.nio;
using java.security;
using javax.crypto;
using javax.crypto.spec;  

public  SecretKey generateKey(int n)  //here n = 256 
{
    KeyGenerator keyGenerator;
    SecretKey key = null;
    try
    {
        keyGenerator = KeyGenerator.getInstance(KEY_ALGORITHOM); //here KEY_ALGORITHOM = "AES"
        keyGenerator.init(n);
        key = keyGenerator.generateKey();
    }
    catch (Exception e)
    {
        //log exception 
    }
    return key;
}

Inner exception: Method not found: 'Void System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.Security.AccessControl.FileSystemRights, System.IO.FileShare, Int32, System.IO.FileOptions)'.

Not getting as to what else is required

eglease
  • 2,445
  • 11
  • 18
  • 28
Shalini Raj
  • 177
  • 2
  • 19
  • 1
    Why are you using some weird Java wrapper to generate a key, when instead you could just use native C#? – MindSwipe Sep 28 '21 at 12:26
  • Actually I was trying to get to use AesGCM 256 encryption decryption but the .net framework is 4.5.2 of the project and could not find how to get AesGCM implementation for that. This was provided as a reference to create hence i went on as such. – Shalini Raj Sep 28 '21 at 12:31
  • Any source recommending a solution written in another language is source that shouldn't be trusted. If you need AES GCM encryption in C# you can check out [this](https://stackoverflow.com/q/46067811/9363973) Q&A – MindSwipe Sep 28 '21 at 12:36
  • @MindSwipe can you suggest some article which can be used for reference for making aes 256 encrypt decryt for .net framework 4.5.2 project – Shalini Raj Sep 28 '21 at 13:49

0 Answers0