.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Where do I ask questions about the System.Security.Cryptography namespace, in particular about DES E

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :.NET Framework

Thanks for leading me right!

View Complete Post

More Related Resource Links

Encryption (System.Security.Cryptography) .Net 2.0

Hi, Query regarding cryptography.  I'm using .net cryptography to encrypt and decrypt files stored on disk on an asp.net website using .Net 2.0 framework.   The code (copied below) works fine to encrypt and decrypt pdf, tif, jpg, etc.  However when it comes to MS Word documents with embedded images and/or tables I get a "Bad data" error when decrypting.   The same document saved to rtf format is encrypted and decrypted without error.  Also simple formatted text documents in Word format (Office 2003) do not throw an error when being decrypted. Would someone care to point out where I'm going wrong? Thanks, code below   _________________________________    Public Sub Encrypt(ByVal Userid As Integer, ByVal FilePath As String)        'Encrypt the file        Try            Dim EncryptedFilePath As String = FilePath & "enc"            Dim clsNetEnCrypt As New NetEncrypt(User)            clsNetEnCrypt.Encrypt(FilePath, EncryptedFilePath)            'Remove the Unencrypted file  

System.Security.Cryptography.CryptographicException (BAD DATA)

Can anyone help me out in this issue ? Any help will be appreciated Stack Trace: <?xml version="1.0" encoding="utf-16"?>   <error    host="localhost"    type="System.Security.Cryptography.CryptographicException"     message="Bad Data.&#xD;&#xA;"     source="mscorlib"     detail="System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.  System.Exception: Bad Data.&#xD;&#xA; System.Security.Cryptography.CryptographicException: Bad Data.&#xD;&#xA;&#xD;&#xA;   at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)&#xD;&#xA;   at System.Security.Cryptography.Utils._DecryptData(SafeKeyHandle hKey, Byte[] data, Int32 ib, Int32 cb, Byte[]&amp; outputBuffer, Int32 outputOffset, PaddingMode PaddingMode, Boolean fDone)&#xD;&#xA;   at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)&#xD;&#xA;   at System.Security.Cryptography.CryptoStream.FlushFinalBlock()&#xD;&#xA;  CODE:   public static string Decrypt(string stringToDecrypt, string sEncryptionKey)         {    &

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





When i tried to use a third party web service  using IIS  , i am getting the following Error

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

[CryptographicException: The system cannot find the file specified.
   System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +1459868
   System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +55
   System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +79
   System.Security.Cryptography.RSACryptoServiceProvider.ExportParameters(Boolean includePrivateParameters) +38
   System.Security.Cryptography.RSA.ToXmlString(Boolean includePrivateParameters) +41
   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.a() +158
   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.RequestLogin(String reasonMessage) +200
   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.GetNewSecureSessionToken(Boolean attemptLogin) +148

How to Serialize System.Security.Cryptography objects?



I'm creating a solution for a multi-webserver farm that basically receives and stores files for remote users.  The files arrive at our load balancer in small, HTTPS encrypted chunks that can be anywhere from 1k to >1024k in size, and typically represent a fraction of the overall file being received.

After all the chunks have been received, but before storing the file, we create a sha1 hash of the file just sent in by the user.  If it already matches the hash of something in storage, we merely store a pointer to the originally stored file, instead of storing another copy.

(For reasons outside the scope of this discussion, the client is incapable of computing the hash on its own, and must sent the file to the server).


The Problem:

The "chunk-storage" infrastructure is sufficiently distributed that a given stream of chunks can be processed on any number of web servers.  The same is true of the ASP Session variable, which is stored on a SQL cluster in the farm, so any web server can pick up where a prior server's session left off.

The SHA1 computation, however, currently runs after receiving the last chunk of data, which creates an unnecessary I/O spike and delay in deciding whether or not to commit the file to storage or use a pointer:  The whole file is retrieved from stor



hello i have the following problem

i have upload my content to hosting server but i get the following error

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of typ

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPerm


Good Day all,

Having an issue with an outside user accessing my IIS7 box. I do not have this problem when running the website from my host machine. I found this post: Http://forums.asp.net/t/1371394.aspx. I assure you that this is not a solution because I am not storing any of my files on a network share. 

What do you think my approach should be. 

I already have read rights to IIS user to my BIN folder. 

Thanks for the help. 

Security: Applying Cryptography Using The CNG API In Windows Vista


Cryptography Next Generation (CNG) is meant to be a long-term replacement for the CryptoAPI, providing replacements for all of the cryptographic primitives it offered.

Kenny Kerr

MSDN Magazine July 2007

Windows Server 2003: Discover Improved System Info, New Kernel, Debugging, Security, and UI APIs


There's a lot to say about Windows Server 2003. First of all, it's the first operating system with built-in .NET Framework support, and it's the first 64-bit OS from Microsoft. But wait, there's more! There are lots of new features and APIs in this version as well. For instance, Windows Server 2003 features Hot Add Memory and a number of other arcane new tidbits. There are new APIs for handling threads, directories, and files, and new features like the low fragmentation heap for managing memory and system information. There's vectored exception handling and new UI APIs as well.OS internals expert Matt Pietrek takes a look at the additions he finds most interesting and useful so you'll have a good place to start when you dive into Windows Server 2003.

Matt Pietrek

MSDN Magazine June 2003

Windows Forms: .NET Framework 1.1 Provides Expanded Namespace, Security, and Language Support for Yo


With the much-anticipated release of the .NET Framework 1.1, developers are eager to know what's been added to their programming bag of tricks. In this article, the author focuses on new developments in Windows Forms, such as namespace additions, support for hosting managed controls in unmanaged clients, and designer support for C++ and J#. Integrated access to the Compact Framework and new mobile code security settings also make this release noteworthy. Along with these features, the author reviews the best ways to handle multiple versions of the common language runtime and highlights some potential pitfalls.

Chris Sells

MSDN Magazine March 2003

Security: Protect Private Data with the Cryptography Namespaces of the .NET Framework


The .NET Framework includes a set of cryptographic services that extend the services provided by Windows through the Crypto API. In this article, the author explores the System.Security.Cryptography namespace and the programming model used to apply cryptographic transformations. He discusses reasons why cryptography is easier in .NET than it was before, including the easy programmatic acccess developers have to the cryptography APIs and the difference between symmetric and asymmetric algorithms. Along the way, a brief discussion of the most widely used algorithms, including RSA, DSA, Rijndael, SHA, and other hash algorithms, is provided.

Dan Fox

MSDN Magazine June 2002

Security.Cryptography Vs CAPICOM



I hope this is the right place to write this question.

I have an old system written in ASP that uses Capicom and made encryption to MD5.

In the system I am now building I wish to use the  .NET Security.Cryptography class to hash to MD5 - but I have a problem - the hashing result for a string is different from Capicom and the Security.Cryptography MD5.

How could that be?

Redirect to Security Questions if Site accessed from unrecognized computer?


I'm fairly new to ASP.NET and i'm using the Membership Provider.  I have the need to do similar to some banking sites. Baically I need to track "authorized" computers/ip's for a user.  If the user accesses the site form a recognized Computer/IP then the user is allowed into the app after successful login.  If the computer/IP is not recognized I need to redirect them to a screen to answer the security question setup in fhte Membership Provider.

Has anyone done anything like this or can anyone point me to any examples?  I did a search, but can't seem to find anything.

My idea is to maintain a list of authorized computers/IP addresses and check them on initial login.  If the IP address isn't found I can redirect them to the questions.  My concern is that they are then actually authenticated and could enter any of the site URL's as an authenticated user.

Any suggestions greatly appreciated. 

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlCli

I have created a windows library control that accesses a local sql database I tried the following strings for connecting Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true" Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"   I am not running the webpage in a virtual directory but in C:\Inetpub\wwwroot\usercontrol and I have a simple index.html that tries to read from an sql db but throws the error System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)   at System.Security.PermissionSet.Demand()   at System.Data.Common.DbConnectionOptions.DemandPermission()   at System.Data.SqlClient.SqlConnection.PermissionDemand()   at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, etc etc  The action that failed was:DemandThe type of the first permission that failed was:System.Data.SqlClient.SqlClientPermissionThe Zone of the assembly that fa

SMO System.Security.SecurityException

Hello everybody I wrote a backup procedure using smo. this procedure works great on my dev box, but once deployed to the hosting company's web server it throws above exception ("System.Security.SecurityException: That assembly does not allow partially trusted callers.") I did some research on the subject and it seems that hosting companies give you only medium trust in the config file and hence cannot access smo. My hosting admin is a great fellow (www.alsonetworks.com, recommended!) and is willing to help out, so he told me that he: A. installed smo 2008 in the GAC B. added them to the medium.config file Even so, I still receive the error. Now, I'm pretty sure he'd do anything possible to get it to work (sans giving full trust) but i'd got to tell him what to do. So can anybody advise any additional steps that can be done to get this to work? my site is built with vb asp.net 3.5 against mssql 2008, but the hosting site uses mssql 2005. I appreciate your help and advice PS. I've also read a lot about AllowPartiallyTrustedCallers, but I understand that it is irrelevant here as i have not written the assembly. it would be something ms could/should do. is that correct?   heres the code : Public Shared Sub Backup() Dim sqlCon = New SqlConnection(ConfigurationManager.ConnectionStrings("Main").ConnectionString) Dim conn As New Server

The type or namespace name 'Linq' does not exist in the namespace 'System'

Hi, I uploaded my website to the server, and I have there a working with wcf - it should be fw 3.5 I saw that fw 3.5 is installed on the server and also we have there fw 3.0 sp1. I run my website : www.qenglishcenter.com and I'm getting an error : The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) shouldn't System.linq be already existed ? Thanks for any reply.  

Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtec

I have a windows service that runs on client machines and connects to a WCF service on a server.  This windows service seems to work fine on Windows XP, Vista and 7  machines, but when I try and run it on a Server 2008 R2 machine I get the following error: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceModel/bindings: Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement' from assembly 'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (C:\Program Files (x86)\MyFolder\MyApp\MyAppWinSVC.exe.Config line 4) ---> System.TypeLoadException: Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement' from assembly 'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.    at System.ServiceModel.Configuration.HttpTransportSecurityElement.get_Properties() I have the 3.5 sp1 feature installed. The only thing I have found online that is remotely similar is this MS hotfix: http://support.microsoft.com/kb/2262911 But when I try and apply it, it says that it isn't for my computer. Does anyone have any ideas how to resolve this issue?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend