C# の初心者 - Powershell と Java の管理者からの移行。MS 関数を使用してファイルを復号化しています。
static void DecryptFile(string sInputFilename, string sOutputFilename, string sKey)
    {
        DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
        //A 64 bit key and IV is required for this provider.
        //Set secret key For DES algorithm.
        DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
        //Set initialization vector.
        DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
        //Create a file stream to read the encrypted file back.
        FileStream fsread = new FileStream(sInputFilename,
           FileMode.Open,
           FileAccess.Read);
        //Create a DES decryptor from the DES instance.
        ICryptoTransform desdecrypt = DES.CreateDecryptor();
        //Create crypto stream set to read and do a 
        //DES decryption transform on incoming bytes.
        CryptoStream cryptostreamDecr = new CryptoStream(fsread,
           desdecrypt,
           CryptoStreamMode.Read);
        //Print the contents of the decrypted file.
        StreamWriter fsDecrypted = new StreamWriter(sOutputFilename);
        fsDecrypted.Write(new StreamReader(cryptostreamDecr).ReadToEnd());
        fsDecrypted.Flush();
        fsDecrypted.Close();
    }
現時点では、さまざまなボタンを介してさまざまな形式で呼び出しています。
        string decryptionKey = File.ReadAllText(@"C:\ThickClient\secretKey.skey");
        DecryptFile("C:\\ThickClient\\Encrypted.enc", "C:\\ThickClient\\tempPWDump.enc", decryptionKey);
        string decryptedPW = File.ReadAllText(@"C:\ThickClient\tempPWDump.enc");
        File.Delete(@"C:\ThickClient\tempPWDump.enc");
そして、各フォームで を定義し、static void DecryptFile {code}それを各フォームで新しい変数に呼び出して利用する必要があります。Windowsフォームのどこでそれを定義し、グローバル変数を設定して、すべてのフォームで使用できるようにすることができますか?