Click here to Skip to main content
15,914,608 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: System.IndexOutOfRangeException: There is no row at position 0 Pin
Venkatesh Mookkan13-Jun-07 20:41
Venkatesh Mookkan13-Jun-07 20:41 
Questionencrypt the coookies Pin
saravanan0513-Jun-07 18:13
saravanan0513-Jun-07 18:13 
AnswerRe: encrypt the coookies Pin
Sylvester george13-Jun-07 18:28
Sylvester george13-Jun-07 18:28 
QuestionRe: encrypt the coookies Pin
saravanan0513-Jun-07 19:11
saravanan0513-Jun-07 19:11 
AnswerRe: encrypt the coookies Pin
Sylvester george13-Jun-07 19:24
Sylvester george13-Jun-07 19:24 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:08
saravanan0513-Jun-07 20:08 
AnswerRe: encrypt the coookies Pin
Sathesh Sakthivel13-Jun-07 19:29
Sathesh Sakthivel13-Jun-07 19:29 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:09
saravanan0513-Jun-07 20:09 
hi satips

i encrypeted sucessfully

the username and password saved in encryped form in cookies


how can i decrypt that username,password

I use this code only


Public Shared Function encrypt(ByVal val As String, ByVal seed As Byte()) As String
Dim KEY_64 As Byte()
KEY_64 = seed
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim ms As New MemoryStream
Dim cs As New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), CryptoStreamMode.Write)
Dim sw As New StreamWriter(cs)
sw.Write(val)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
Return Convert.ToBase64String(ms.GetBuffer(), 0, Convert.ToInt32(ms.Length))
End If
Return ""
End Function




Public Shared Function decrypt(ByVal val As String, ByVal seed As String) As String
Dim KEY_64 As Byte() = Convert.FromBase64String(seed)
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim buffer As Byte() = Convert.FromBase64String(val)
Dim ms As New MemoryStream(buffer)
Dim cs As New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), CryptoStreamMode.Read)
Dim sr As New StreamReader(cs)
Return sr.ReadToEnd()
End If
Return ""
End Function



Public Shared Function CreateSalt(ByVal size As Integer) As Byte()
' Generate a cryptographic random number using the cryptographic service provider
Dim rng As New RNGCryptoServiceProvider
Dim buff As Byte() = New Byte(size - 1) {}
rng.GetBytes(buff)
' Return a Base64 string representation of the random number
Return buff
End Function





Private Sub butuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butuser.Click

Dim username As String
Dim password As String
Dim checkbox As String


username = txtusername.Text
password = txtpassword.Text


If username <> "" Then
'if Username is not null
Dim salt As Array


salt = CreateSalt(8)
username = encrypt(username, salt)
'encrypting the password to salt 8 algorithm
username = username.Replace("'", "''")
End If
If password <> "" Then
Dim salt As Array
'if password is not null
salt = CreateSalt(8)
password = encrypt(password, salt)
'encrypting the password to salt 8 algorithm
password = password.Replace("'", "''")
End If

regards
saravanan
GeneralRe: encrypt the coookies Pin
Sathesh Sakthivel13-Jun-07 20:13
Sathesh Sakthivel13-Jun-07 20:13 
QuestionRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:26
saravanan0513-Jun-07 20:26 
AnswerRe: encrypt the coookies Pin
Sathesh Sakthivel13-Jun-07 20:30
Sathesh Sakthivel13-Jun-07 20:30 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:34
saravanan0513-Jun-07 20:34 
GeneralRe: encrypt the coookies Pin
Sathesh Sakthivel13-Jun-07 20:37
Sathesh Sakthivel13-Jun-07 20:37 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:41
saravanan0513-Jun-07 20:41 
GeneralRe: encrypt the coookies Pin
Sylvester george13-Jun-07 20:45
Sylvester george13-Jun-07 20:45 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:51
saravanan0513-Jun-07 20:51 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 21:12
saravanan0513-Jun-07 21:12 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 21:32
saravanan0513-Jun-07 21:32 
QuestionHelp using CTYPE [modified] Pin
ASPnoob13-Jun-07 17:58
ASPnoob13-Jun-07 17:58 
QuestionRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 18:11
Venkatesh Mookkan13-Jun-07 18:11 
AnswerRe: Help using CTYPE Pin
ASPnoob13-Jun-07 18:16
ASPnoob13-Jun-07 18:16 
GeneralRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 18:28
Venkatesh Mookkan13-Jun-07 18:28 
GeneralRe: Help using CTYPE [modified] Pin
ASPnoob13-Jun-07 19:02
ASPnoob13-Jun-07 19:02 
AnswerRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 19:38
Venkatesh Mookkan13-Jun-07 19:38 
GeneralRe: Help using CTYPE Pin
ASPnoob13-Jun-07 20:15
ASPnoob13-Jun-07 20:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.