Click here to Skip to main content
15,845,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a vb function to code the string to asscii chars for some security purpose.
And this string info is stored to database.
Now i am fetching the same (password) data from a c# mvc application.
But when i cast the same string using c# code it returns a different string of ascii chars.
Its a user login process.I am using same users in both vb and c# applications.The users and their passwords will be saved from vb application.
The codes in vb and c#,
VB
Public Function DecodeId(ByVal mmId) As String
       Dim DVal As String
       Dim I As Integer
       On Error Resume Next
       If mmId.ToString.Length < 10 Then mmId = mmId.ToString.PadRight(10)
       DVal = ""
       For I = 1 To mmId.ToString.Length
           DVal = DVal & Chr(Asc(Mid(mmId, I, 1)) + 58)
       Next
       DecodeId = DVal
   End Function
c#

    public string DecodeId(string mmId)
             {
               	string DVal = string.Empty ;
               	int I = 0;
                            
               	for (I = 0; I <= mmId.Length-1; I++) {
                    char c = (char)(System.Convert.ToInt32(mmId[I]) + 58);
                    //int x = (System.Convert.ToInt32(mmId[I]) + 58);
                   // char nw = (Char)x;
                   // string s = char.ConvertFromUtf32(x).ToString();
                    DVal = DVal + s.ToString();
               	}
               	return DVal;
           
              }

Please reply if there is any difference in ascii values according o.s or prgmng languages etc (the ascii value for 155 is '>' but from my c# code it gives '""').
Please reply
Thanks
Posted

1 solution

Don't do that: hash your passwords instead. There is some information on how to do it here: Password Storage: How to do it.[^] and usingh SHA or MD5 will make it work very easily in both languages.
 
Share this answer
 
Comments
NIDHIN.C 2-Apr-15 5:38am    
You mean that method will give wrong result? ie,ascii coding?
NIDHIN.C 2-Apr-15 5:42am    
//Password Storage: How to do it.[^] //
Its a nice article
Thanks
:)
OriginalGriff 2-Apr-15 5:48am    
You're welcome!
phil.o 2-Apr-15 5:56am    
Downvote countered.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900