Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 December 7th, 2004, 02:52 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default retrival of decrypted data

Hi
We are working on ASP.NET back end database SqlServer 2000.

We are encrypting the data in binary format and storing into database without any proble.But while doing the decrypt we need to retrive binary data from database and need to pass our decrypt function.here we are facing proble.when we try to fetch data from databse its always saying nodata error.but when we open table its showing rows.Here actually we need to pass byte datatype to decrypt function.

Basically i want these two steps

1.Retriving binary(encrypted) data from table
2.decryption of retrived data and displaying in datagrid or table.

table name test
columns
fld1 binary 50
fld2 binary 50


for encrypt and decrypt below function are using

private byte[] EncryptText( ICryptoTransform Encryptor, string Data )
        {
            using( MemoryStream dataStream = new MemoryStream() )
            {
                // encrypt data with received symmetric key
                using( CryptoStream streamEncrypt = new CryptoStream( dataStream, Encryptor, CryptoStreamMode.Write ) )
                {
                    using( StreamWriter encryptStreamWriter = new StreamWriter( streamEncrypt ) )
                    {
                        encryptStreamWriter.Write( Data );
                        encryptStreamWriter.Close();
                    }
                    streamEncrypt.Close();
                }
                byte[] encryptedData = dataStream.ToArray();
                dataStream.Close();
                return encryptedData;
            }
        }

        private string DecryptText( ICryptoTransform Decryptor, byte[] Data )
        {
            using( MemoryStream receivedStream = new MemoryStream( Data ) )
            {
                string text;
                // decrypt data with symmetric key
                using( CryptoStream streamDecrypt = new CryptoStream( receivedStream, Decryptor, CryptoStreamMode.Read ) )
                {
                    StreamReader decryptStreamReader = new StreamReader( streamDecrypt );
                    text = decryptStreamReader.ReadToEnd();
                    // do not call close method for StreamReader or CryptoStream if CryptoStream opened in Read mode
                    // "Stream doesn't support writing" error will be generated
                    // decryptStreamReader.Close();
                    // streamDecrypt.Close();
                }
                receivedStream.Close();
                return text;
            }
        }










Similar Threads
Thread Thread Starter Forum Replies Last Post
asp 3.0 classic&access *formula retrival)? saad_rashad Classic ASP Databases 3 February 18th, 2007 03:47 PM
Data Retrival xbenx Classic ASP Basics 22 January 18th, 2006 06:17 PM
Data Retrival xbenx Classic ASP Professional 0 January 4th, 2006 10:54 PM
Retrival of Server Side DateTime with ACCESS dubey.kuldeep Access 2 November 1st, 2005 12:37 PM





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