473,473 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with decryption


I have solved my previous decryption problem wherein i was getting a
specified cast is not valid msg.
My new problem is htis: The password is not being decrypted. I am using
Rijndael. The code is from Pro ASP.NET 1.1. The string being returned looks
like 3B746F54E9D44721D6CE1337498FDB823B746F54E9D44721D6 CE1337498FDB82
Thanks for any help Ashok

In my db access code:
If dr.Read() Then
encryptedData = CType(dr("Password"), Byte())
End If
Return s.DecryptToString(encryptedData,
CType(HttpContext.Current.Application("Key"), Rijndael))

The decyption function

Public Shared Function DecryptToString(ByVal dataToDecrypt As Byte(), ByVal
crypt As SymmetricAlgorithm) As String
Dim ms As MemoryStream = New MemoryStream
Dim cs As CryptoStream = New CryptoStream(ms, crypt.CreateDecryptor(),
CryptoStreamMode.Write)
cs.Write(dataToDecrypt, 0, dataToDecrypt.Length)
cs.FlushFinalBlock()
Dim r As BinaryReader = New BinaryReader(ms)
ms.Position = 0
Dim decryptedData As String = r.ReadString()
r.Close()
Return decryptedData
End Function

Jan 25 '06 #1
4 1642
Are you sure it's the actual password being stored in the Database? Usually
what is stored is for example , an MD5 hash of the password. The idea is, you
take an MD5 hash of the password supplied by the user during authentication
and compare it against the hash stored in the database.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Showjumper" wrote:

I have solved my previous decryption problem wherein i was getting a
specified cast is not valid msg.
My new problem is htis: The password is not being decrypted. I am using
Rijndael. The code is from Pro ASP.NET 1.1. The string being returned looks
like 3B746F54E9D44721D6CE1337498FDB823B746F54E9D44721D6 CE1337498FDB82
Thanks for any help Ashok

In my db access code:
If dr.Read() Then
encryptedData = CType(dr("Password"), Byte())
End If
Return s.DecryptToString(encryptedData,
CType(HttpContext.Current.Application("Key"), Rijndael))

The decyption function

Public Shared Function DecryptToString(ByVal dataToDecrypt As Byte(), ByVal
crypt As SymmetricAlgorithm) As String
Dim ms As MemoryStream = New MemoryStream
Dim cs As CryptoStream = New CryptoStream(ms, crypt.CreateDecryptor(),
CryptoStreamMode.Write)
cs.Write(dataToDecrypt, 0, dataToDecrypt.Length)
cs.FlushFinalBlock()
Dim r As BinaryReader = New BinaryReader(ms)
ms.Position = 0
Dim decryptedData As String = r.ReadString()
r.Close()
Return decryptedData
End Function

Jan 26 '06 #2
I should just be able to reverse it and decrypt the alphanumeric string
back tot he original password right? Th eobjctive is to be able to
email a user his password.

Jan 27 '06 #3
Showjumper,
No this is not normally the case. A crytographic hash is a unique result of
an operation on an object. If you repeat the hash operation on an identical
object, you can get what should be an identical hash.

The hash itself is NOT decryptable back to the original string. What most
systems do is email you a new Temporary password, and allow you to come back
in and change it if you wish. This is the most secure arrangement.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sh******@gmail.com" wrote:
I should just be able to reverse it and decrypt the alphanumeric string
back tot he original password right? Th eobjctive is to be able to
email a user his password.

Jan 27 '06 #4

The example in Pro ASP.NET 1.1 talks about encrypting credit card #s then
storing it and decrypting it back tot he original string. So i used that as
a basis the passwords.
Ashok
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:E6**********************************@microsof t.com...
Showjumper,
No this is not normally the case. A crytographic hash is a unique result
of
an operation on an object. If you repeat the hash operation on an
identical
object, you can get what should be an identical hash.

The hash itself is NOT decryptable back to the original string. What most
systems do is email you a new Temporary password, and allow you to come
back
in and change it if you wish. This is the most secure arrangement.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sh******@gmail.com" wrote:
I should just be able to reverse it and decrypt the alphanumeric string
back tot he original password right? Th eobjctive is to be able to
email a user his password.


Jan 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: hecklar | last post by:
I'm having a problem with threading (permissions?) in a VB.net Windows application (background service). I'm trying to write an application that processes files, launching a new thread for each...
2
by: hecklar | last post by:
This is my first time posting here, so i apologize if i'm posting in the wrong subgroup or whatever, but here goes... I’m having a problem with threading and events (permissions?) in a VB.net...
2
by: almurph | last post by:
Hi everyone, Can you help me please? I am having a problem with the encryption/decryption of words with the Irish fada in them. The Irish fada is like this: áéíóú/ÁÉÍÓÚ. It's kind of like the...
0
by: Showjumper | last post by:
I solved my previous problem. The new one is that the password is not being decrypted but rather is still in the enrypted format. I am using Rijndael emcryption. Below is the decryption code. And...
5
by: John | last post by:
Hi I am trying to set a new password using the following code; Dim u As MembershipUser = Membership.GetUser(UserName) Dim OldPassword As String OldPassword = u.GetPassword If...
4
by: Ben | last post by:
Hi, i have already posted a more or less similar thread but it's gone unsolved with the flow of the other threads .. When an anonymous user has created an new account (with the...
0
by: Dipanwita | last post by:
I have written a RSA encryption/decryption function in c using the formula a = b^c %n. For solving the equation I have used Squaring and multiplying method for modulo exponentiation . These...
3
by: =?Utf-8?B?TG9yZW4=?= | last post by:
I’m trying to encrypt and decrypt a file in vb.net. I am using the TripleDESCryptoServiceProvider encryption found in System.Security.Cryptography. Below is the code for my Encrypt and Decrypt...
13
by: Tom Andrecht | last post by:
I'm trying to get some encryption/decryption routines going to take care of my data, and while the encryption is working great, I keep running into the message "Padding is invalid and cannot be...
9
by: Betikci Boris | last post by:
I get bored last night and wrote a script that uses xor for encrypt- decrypt, however it woks fine under linux 2.6.25, text and documents are ok, but fails on compressed files *.jpg, *.pdf , etc ....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.