How to decrypt encrypted column of datagrid in c#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all,
Actually my issue is display decrypted password column in datagrid...i know how to decrypt passwords..individually..but based on encrypted column i want to display another column with decrypted passwords..can anybody help me??Below is my datagrid...
<table border="0" cellspacing="0" cellpadding="0" width="606
<colgroup span="1 <col span="1" width="126 <col span="1" width="130 <col span="1" width="101 <col span="1" width="112 <col span="1" width="137 </colgroup>
<tbody>
<tr height="20
<td width="126" height="20 User ID</td>
<td width="130 Password</td>
<td width="101 Role Name</td>
<td width="112 CompanyCode</td>
<td width="137 DecryptedPassword</td>
</tr>
<tr height="20
<td height="20 admin</td>
<td>3SMda6ppl88=</td>
<td>Administrator</td>
<td>PSPL</td>
<td>3SMda6ppl88=</td>
</tr>
<tr height="20
<td height="20 emp</td>
<td>TPSRteVMiCs=</td>
<td>Employee</td>
<td>PSPL</td>
<td>TPSRteVMiCs=</td>
</tr>
<tr height="20
<td height="20 narsing</td>
<td>OyJj8I+cBaM=</td>
<td>Employee</td>
<td>PSPL</td>
<td>OyJj8I+cBaM=</td>
</tr>
<tr height="20
<td height="20 narsing.ankarla</td>
<td>3SMda6ppl88=</td>
<td>Administrator</td>
<td>PSPL</td>
<td>3SMda6ppl88=</td>
</tr>
<tr height="20
<td height="20 NewTestAdmin</td>
<td>xDeTXKwF2g4=</td>
<td>Administrator</td>
<td>PSPL</td>
<td>xDeTXKwF2g4=</td>
</tr>
</tbody>
</table>
and my code is
<span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 DataGrid<span style="color:black
<span style="color:red runat<span style="color:blue ="server"<span style="color:black
<span style="color:red ID<span style="color:blue ="userGrid"<span style="color:black
<span style="color:red AllowSorting<span style="color:blue ="true"<span style="color:black
<span style="color:red AllowPaging<span style="color:blue ="true"<span style="color:red CssClass<span style="color:blue ="medimblack"<span style="color:black
<span style="color:red PagerStyle-HorizontalAlign<span style="color:blue ="left"<span style="color:black
<span style="color:red PagerStyle-Mode<span style="color:blue ="numericPages"<span style="color:red PageSize<span style="color:blue ="10"<span style="color:black
<span style="color:red ShowFooter<span style="color:blue ="false"<span style="color:black
<span style="color:red AutoGenerateColumns<span style="color:blue ="false"<span style="color:black
<span style="color:red Width<span style="color:blue ="100%"<span style="color:black
<span style="color:red Height<span style="color:blue ="100%"<span style="color:red OnItemCommand<span style="color:blue ="userGrid_ItemCommand"<span style="color:black
<span style="color:red OnItemDataBound<span style="color:blue ="userGrid_ItemDataBound"<span style="color:red OnSortCommand<span style="color:blue ="userGrid_SortCommand"<span style="color:black
<span style="color:red OnPageIndexChanged<span style="color:blue ="userGrid_PageIndexChanged"<span style="color:black
<span style="color:red ItemStyle-HorizontalAlign<span style="color:blue ="Left"<span style="color:black
<span style="color:blue ><<span style="color:#a31515 HeaderStyle<span style="color:black
<span style="color:red BackColor<span style="color:blue ="#3481D3"<span style="color:black
<span style="color:red Wrap<span style="color:blue ="false"<span style="color:black
<span style="color:red ForeColor<span style="color:blue ="#ffffff"<span style="color:black
<span style="color:red Font-Bold<span style="color:blue ="true"<span style="color:red HorizontalAlign<span style="color:blue ="Center"<span style="color:black
<span style="color:blue /><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 ItemStyle<span style="color:black
<span style="color:blue /><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 AlternatingItemStyle<span style="color:black
<span style="color:red BackColor<span style="color:blue ="#FFFFFF"<span style="color:black
<span style="color:blue /> <span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue <<span style="color:#a31515 FooterStyle<span style="color:black
<span style="color:blue /> <span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue <<span style="color:#a31515 PagerStyle<span style="color:black
<span style="color:red BackColor<span style="color:blue ="#3481D3"<span style="color:black
<span style="color:red ForeColor<span style="color:blue ="#ffffff"<span style="color:black
<span style="color:blue /><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue <<span style="color:#a31515 Columns<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:black
<span style="color:red DataField<span style="color:blue ="UserID"<span style="color:black
<span style="color:red HeaderText<span style="color:blue ="User ID"<span style="color:black
<span style="color:red SortExpression<span style="color:blue ="UserID"<span style="color:black
<span style="color:red HeaderStyle-Wrap<span style="color:blue ="false <span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:black
<span style="color:red DataField<span style="color:blue ="Password"<span style="color:black
<span style="color:red HeaderText<span style="color:blue ="Password"<span style="color:black
<span style="color:red SortExpression<span style="color:blue ="Password"<span style="color:black
<span style="color:red HeaderStyle-Wrap<span style="color:blue ="false <span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:black
<span style="color:red DataField<span style="color:blue ="RoleName"<span style="color:black
<span style="color:red HeaderText<span style="color:blue ="Role Name"<span style="color:black
<span style="color:red SortExpression<span style="color:blue ="RoleName"<span style="color:black
<span style="color:red HeaderStyle-Wrap<span style="color:blue ="false <span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:black
<span style="color:red DataField<span style="color:blue ="CompanyCode"<span style="color:black
<span style="color:red HeaderText<span style="color:blue ="Company Code"<span style="color:black
<span style="color:red SortExpression<span style="color:blue ="CompanyCode"<span style="color:black
<span style="color:red HeaderStyle-Wrap<span style="color:blue ="false <span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 BoundColumn<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 TemplateColumn<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 HeaderTemplate<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue Password</<span style="color:#a31515 HeaderTemplate<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 ItemTemplate<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 Label<span style="color:blue
<span style="color:red ID<span style="color:blue ="Decrypt"
<span style="color:red runat<span style="color:blue ="server" <span style="color:red Text<span style="color:blue =<%# Decrypt(Eval("Password")) %>>
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 Label<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue </<span style="color:#a31515 ItemTemplate<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <<span style="color:#a31515 ItemStyle<span style="color:blue
<span style="color:red Wrap<span style="color:blue ="false" />
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 TemplateColumn<span style="color:blue >
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue </<span style="color:#a31515 Columns<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:black <span style="color:blue </<span style="color:#a31515 asp<span style="color:blue :<span style="color:#a31515 DataGrid<span style="color:blue ><span style="color:black
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue and my decrypt function is....<span style="color:black
<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small
<p style="line-height:normal; margin:auto auto 0pt <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small public static string Decrypt(string Input)

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small {
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <span style="color:#2b91af Byte<span style="color:blue [] inputByteArray = new
<span style="color:#2b91af Byte<span style="color:blue [Input.Length];

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small try

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small {
<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small key = System.Text.
<p style="line-height:normal; margin:auto auto 0pt <span style="font-family:Times New Roman <span style="font-size:small <span style="color:#2b91af Encoding<span style="color:blue .UTF8.GetBytes

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small (EncryptionKey.Substring(0, 8));
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <span style="color:#2b91af DESCryptoServiceProvider<span style="color:blue des = new
<span style="color:#2b91af DESCryptoServiceProvider<span style="color:blue ();

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small inputByteArray =
<p style="line-height:normal; margin:auto auto 0pt <span style="font-family:Times New Roman <span style="font-size:small <span style="color:#2b91af Convert<span style="color:blue .FromBase64String(Input.Replace(<span style="color:#a31515 "
"<span style="color:blue , <span style="color:#a31515 "+"<span style="color:blue ));

<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <span style="color:#2b91af MemoryStream<span style="color:blue ms = new
<span style="color:#2b91af MemoryStream<span style="color:blue ();

<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <span style="color:#2b91af CryptoStream<span style="color:blue cs = new
<span style="color:#2b91af CryptoStream<span style="color:blue (ms, des.CreateDecryptor(key, IV),<span style="color:#2b91af CryptoStreamMode<span style="color:blue .Write);

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small cs.Write(inputByteArray, 0, inputByteArray.Length);
<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small cs.FlushFinalBlock();
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue <span style="color:#2b91af Encoding<span style="color:blue encoding =
<span style="color:#2b91af Encoding<span style="color:blue .UTF8;

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small return encoding.GetString(ms.ToArray());

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small }
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue catch (<span style="color:#2b91af Exception<span style="color:blue ex)

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small {
<p style="line-height:normal <span style="font-family:Times New Roman <span style="font-size:small <span style="color:blue return
<span style="color:#a31515 ""<span style="color:blue ;
<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small throw ex;

<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small }
<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small }
<p style="line-height:normal <span style="color:blue <span style="font-family:Times New Roman <span style="font-size:small Can anybody tell me how to bind this decrypt function to grdview...in which event..and how??
<p style="margin:0in 0in 10pt <span style="font-family:Calibri; color:#000000; font-size:small

<br/>

View the full article
 
Back
Top