Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2009, 01:50 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default Need Help with C# Crypto Classes

Hi

I am trying to do some initial tests on my hosting site through a sub domain I made but I keep getting this error.

Code:
Server Error in '/' Application.

               The system cannot find the file specified.
 

                             Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

              Exception Details: System.Security.Cryptography.CryptographicException: The system cannot find the file specified.


             Source Error: 

                                                                       Line 24: 
Line 25:             // protect the key 
Line 26:             key = ProtectedData.Protect(key, null, DataProtectionScope.CurrentUser);
Line 27: 
Line 28:                                                                
              Source File:  e:\domains\interactivejapanese.com\wwwroot\mytest101\App_Code\generateEncryption.cs    Line:  26             

             Stack Trace: 

                                                                       [CryptographicException: The system cannot find the file specified.
]
   System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope) +453
   EncryptedPayPal_API_Credentials.generateEncryption.GenerateKey(String targetPath) in e:\domains\interactivejapanese.com\wwwroot\mytest101\App_Code\generateEncryption.cs:26
   Encryptor.btn_generate_Click(Object sender, EventArgs e) in e:\domains\interactivejapanese.com\wwwroot\mytest101\Encryptor.aspx.cs:22
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
                                                              
My code is this:

Code:
 public static string GenerateKey(string targetPath)
        {
           
            // uses default encryption choosen by microsoft - currently it is Rijndael.
            SymmetricAlgorithm Algorithm = SymmetricAlgorithm.Create();
           
            // generate the key
            Algorithm.GenerateKey();

            // store key as bytes
            byte[] key = Algorithm.Key;

            // protect the key 
            key = ProtectedData.Protect(key, null, DataProtectionScope.CurrentUser);


            // save the key in a file
            using (FileStream fs = new FileStream(targetPath, FileMode.Create))
            {
                fs.Write(key, 0, key.Length);
            }

            return targetPath;

        }
So I don't know how to solve this I guess I don't have permissions to use DataScope on my hosting site(not sure if they will give me permissions or what) so is there away around this or something like I really want to use DataScope because I need to protect my files.

Thanks

Update.

Seems like my hosting company will not give me the permissions that is needed since they apparently are all admin privileges.

Last edited by chobo2; March 23rd, 2009 at 02:08 PM..
The Following User Says Thank You to chobo2 For This Useful Post:





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to figure out blockSize from a Crypto Key chobo2 C# 2008 aka C# 3.0 0 November 13th, 2008 12:52 AM
About Classes. wdw BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 29th, 2005 08:46 AM
Missing Crypto algorithm Stephen Lam All Other Wrox Books 0 May 22nd, 2005 09:10 PM
Classes CodeMonkeys C# 3 August 18th, 2004 11:14 AM
Crypto problems pilmart Pro VB 6 0 June 10th, 2004 09:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.