|
-
Jun 11th, 2003, 04:03 AM
#1
Thread Starter
Hyperactive Member
Encrypt function (vb-> C#) [Resolved]
Hello
Am trying to translate a vb-encrypt function to C# but I'm stuck.
VB Code:
Dim strChar, L, x
L = Len(strKey)
For x = 1 To Len(strValue)
strChar = Asc(Mid$(strKey, (x Mod L) - L * ((x Mod L) = 0), 1))
Mid$(strValue, x, 1) = Chr$(Asc(Mid$(strValue, x, 1)) Xor strChar)
Next
I have some trouble finding the correct functions for string manipulation.
mid = .substring()
chr$ = ? (is it (char) )
ASC = ? (i think it is system.text.asciiencoding)
mod = ? (cant find it in system.math)
Xor = ? (cant find it in system.math)
Last edited by onerrorgoto; Jul 8th, 2003 at 02:07 AM.
Onerrorgoto
Dont be to optimistic, the light at the end of the tunnel might be a train
-
Jun 11th, 2003, 07:01 AM
#2
Sleep mode
It's hard to translate from VB6 to C# esp . If you don't have to , then you better use the .NET way in Cryptographic class . Not that complicated . http://www.codeproject.com/csharp/Encryption.asp
-
Jun 11th, 2003, 07:20 AM
#3
Thread Starter
Hyperactive Member
Thanks
We have already looked att the crypto-class but our problem is that the app we are translating saves the decrypted strings in a db and if we change the decrypt-function we cant read/save the values.
that why we have to translate it
Onerrorgoto
Dont be to optimistic, the light at the end of the tunnel might be a train
-
Jun 11th, 2003, 07:23 AM
#4
Sleep mode
aha , OK . Try to convert this VB6 code into VB.NET , when you get these functions to work , save them in a class file , ship them in a dll file , then you can *I think* use it within your C# proj .
-
Jun 11th, 2003, 09:33 AM
#5
here's how to use asc / char translations in a simple button click , this may help with some of your answers .
Code:
private void button1_Click(object sender, System.EventArgs e)
{
string message="my message ";
Byte[] bt = System.Text.Encoding.ASCII.GetBytes(message);
for (int i=1; i!=bt.Length ; i++)
{
Console.Write(bt[i]); //// asc chars for each letter
string s= System.Text.Encoding.ASCII.GetString(bt, 0, i);
MessageBox.Show(s); /// show letter converted back from asc chars.
}
}
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jun 11th, 2003, 07:21 PM
#6
Code:
System.Data.SqlTypes.SqlInt32.Mod
thats the Mod function in c#
Code:
System.Data.SqlTypes.SqlInt32.Xor
and Xor.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jun 12th, 2003, 07:39 PM
#7
yay gay
mod -> % operator, ex : 3 % 1
chr -> "myString"[0] , where 0 is the chr you want to see
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|