CS0116命名空间不能直接包含诸如字段或方法之类的成员

时间:2019-12-23 22:47:39

标签: c#

public static byte[] Decrypt(byte[] input, string key) /// CS0116 A namespace cannot directly contain members such as fields or methods
{
    PasswordDeriveBytes pdb =
     new PasswordDeriveBytes(key,
      new byte[] {
    0x43,
    0x87,
    0x23,
    0x72
      });
    MemoryStream ms = new MemoryStream();
    Aes aes = new AesManaged();
    aes.Key = pdb.GetBytes(aes.KeySize / 8);
    aes.IV = pdb.GetBytes(aes.BlockSize / 8);
    CryptoStream cs = new CryptoStream(ms,
     aes.CreateDecryptor(), CryptoStreamMode.Write);
    cs.Write(input, 0, input.Length);
    cs.Close();
    return ms.ToArray();
}

我该如何解决?

0 个答案:

没有答案