|
|
nlarson11 wrote: research reflection
Thank you a lot for your answer.
The reflection was a perfect solution for my problem.
Regards,
JosBerb
|
|
|
|
|
Hello,
I have a requirement where I need to use Encryption/Decryption in ASP and ASP.NET application visa versa.
I have used a Blowfish .NET dll and tried to use it but on Windows 2003 SERVER backward compatibility fails.
Please help to get a VB code through which I can encrypt and decrypt a string using a Key.
Regards,
Pavas
-----------------------
[http://longjump.com/]
Dynamic business applications that manage and coordinate teams and information
-----------------------
|
|
|
|
|
You should look at System.Security.Cryptography Namespace which contains a bunch of classes use one which suits your need.
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
This is very simple but it works!
Public Class CL_EnCrypt
Private sPsw As String = "XAN4519CEAN4719"
Private sBox(255) As String
Private sKey(255) As String
Public Property Password() As String
Get
Return sPsw
End Get
Set(ByVal sVal As String)
sPsw = sVal
End Set
End Property
Public Function DeCrypt(ByVal sWord As String) As String
If sPsw = "" Then
MsgBox("Error you must set a password first.", MsgBoxStyle.Information, "Password not set")
Return ""
End If
Return EnDeCrypt(sWord)
End Function
Public Function EnCrypt(ByVal sWord As String) As String
If sPsw = "" Then
MsgBox("Error you must set a password first.", MsgBoxStyle.Information, "Password not set")
Return ""
End If
Return EnDeCrypt(sWord)
End Function
Private Sub RC4Initialize()
Dim sSwap As String = ""
Dim A, B As Integer
Try
For A = 0 To 255
sKey(A) = Asc(Mid$(sPsw, (A Mod sPsw.Length) + 1, 1))
sBox(A) = A
Next
B = 0
For A = 0 To 255
B = (B + sBox(A) + sKey(A)) Mod 256
sSwap = sBox(A)
sBox(A) = sBox(B)
sBox(B) = sSwap
Next
Catch ex As Exception
MessageBox.Show("Encription Error - " + ex.Message, "Encription Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
Private Function EnDeCrypt(ByVal sPlainTxt As String) As String
'This routine does all the work. Call it both to ENcrypt and to DEcrypt your data.
Dim A, I, J, K As Integer
Dim sCipherBy, sCipher, sTemp As String
Try
sCipherBy = ""
sCipher = ""
sTemp = ""
I = 0
J = 0
RC4Initialize()
For A = 1 To sPlainTxt.Length
I = (I + 1) Mod 256
J = (J + sBox(I)) Mod 256
sTemp = sBox(I)
sBox(I) = sBox(J)
sBox(J) = sTemp
K = sBox((sBox(I) + sBox(J)) Mod 256)
sCipherBy = Asc(Mid$(sPlainTxt, A, 1)) Xor K
sCipher = sCipher + Chr(sCipherBy)
Next
Return sCipher
Catch ex As Exception
MessageBox.Show("Encription Error - " + ex.Message, "Encription Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return ""
End Try
End Function
End Class
|
|
|
|
|
Thanks for the reply,
But I need to use the code in VB and .NET so it should work on both ASP and ASP.NET.
Hence I am looking for a code that is in VB and it has forward compatability.
Backward compatability gives issue in Windows 2003 server. So i want some tuhing with forward compatability
Regards,
Pavas
-----------------------
[http://longjump.com/]
Dynamic business applications that manage and coordinate teams and information
-----------------------
|
|
|
|
|
Below is an encryption/decryption class I have written and use.
To Encrypt, pass the the encrypt method the text to encrypt and an encryption key. As a result a string is returned with the encrypted text.
To decrypt pass the encrypted text to the decrypt method along with the original encrytion key and as a result you should now have the original text returned by the method.
Public Class Cryptography<br />
<br />
Public Shared Function Encrypt(ByVal Text As String, ByVal Key As String) As String<br />
Dim sEncrypted As String = ""<br />
Dim iKey As Integer = 0<br />
If Key.Trim.Length = 0 Then Throw New Exception("An encryption key is required")<br />
<br />
For iChar As Integer = 0 To Text.Trim.Length - 1<br />
Dim iTextChar As Integer = Asc(Text.Substring(iChar, 1))<br />
Dim iKeyChar As Integer = Asc(Key.Substring(iKey, 1))<br />
Dim iCharacterIndex As Integer = iTextChar + iKeyChar + iChar<br />
<br />
While iCharacterIndex > 255<br />
iCharacterIndex = iCharacterIndex - 255<br />
End While<br />
<br />
sEncrypted &= Chr(iCharacterIndex)<br />
iKey += 1<br />
If iKey > (Key.Trim.Length - 1) Then iKey = 0<br />
Next<br />
Return sEncrypted<br />
<br />
End Function<br />
<br />
Public Shared Function Decrypt(ByVal EncryptedText As String, ByVal Key As String) As String<br />
Dim sDecrypted As String = ""<br />
Dim iKey As Integer = 0<br />
If Key.Trim.Length = 0 Then Throw New Exception("An encryption key is required")<br />
<br />
For iChar As Integer = 0 To EncryptedText.Trim.Length - 1<br />
Dim iTextChar As Integer = Asc(EncryptedText.Substring(iChar, 1))<br />
Dim iKeyChar As Integer = Asc(Key.Substring(iKey, 1))<br />
Dim iCharacterIndex As Integer = iTextChar - iKeyChar - iChar<br />
<br />
While iCharacterIndex < 1<br />
iCharacterIndex = iCharacterIndex + 255<br />
End While<br />
<br />
sDecrypted &= Chr(iCharacterIndex)<br />
iKey += 1<br />
If iKey > (Key.Trim.Length - 1) Then iKey = 0<br />
Next<br />
Return sDecrypted<br />
<br />
End Function<br />
<br />
End Class
Regards
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi Steve,
I strongly recommend you take a look at the System.Security.Cryptography namespace. "Homebrew" cryptographic algorithms are almost never secure, and are often vulnerable to the most trivial of cryptanalysis.
If you need to protect data then pick a reputable algorithm.
|
|
|
|
|
is it possible to use a WebBrowser control to open an existing web page and populate the text controls on the web page from VB.NET code? NOTE: the web page could be any existing page. For example www.google.com. Browse to Google and put some search text into the text control and press the Search button.
mcnewsxp
|
|
|
|
|
hi all,
as per my projects needs i am using checklistbox. now the requirement is to multiselect the items of checklistbox with shift or control key pressed, which is not possible with this control.
now i try to use the datagridview control as checklistbox.
- i hide the column header and row header
- the first column is datagridviewcheckboxcolumn
- the second column is datagridviewtextboxcolumn
for MOUSE handling
- i write my code on datagridview_cellclick event (that works perfectly as per need)
for KEYBOARED handling
- i write the same code on datagridview_cellvaluechanged event ( their the problem is )
when i check the checkbox, i need to change the other controls value accordingly. but the event fires when selection changed.
- i also try datagridview_selectionchange event but in that case i have to change the selection to get the values get change
does some one have any kind of idea to solve that problem.
thanks in advance
help everyone
|
|
|
|
|
I have been creating a custom control the base of which is an Panel and consists of a collection of Buttons.
The problem I am experiencing is when I try to add a button to the Button Collection, of the control, in the Form designer, an "Error creating window handle" error is generated.
If I add the button in code in the form Load event the button is added with no errors.
The offending code, which is appart of my Button class, is as follows :-
Protected Overrides Sub WndProc(ByRef m As Message)<br />
MyBase.WndProc(m)<br />
End Sub
On investigation the values of m are :-
LParam : 0
Msg : 133
Result : 0
WParam : 1
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Strange one this, but I have resolved the problem. I say I resolved it; what I have done is Restarted my PC and hay-presto it's working as expected.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hello,
my problem is: in my environment several EXCEL applications are running. I have to pick one specific application ( I have to check the application if it is the correct one).
EApp = Ctype(Marshal.GetActiveObject("Excel.Application"), Excel.Application)
returns only the first registered process with the correct name (and of course "my" application is usually not the first one). I need something like
"
Dim P() as Process = Process.GetProcessByName("Excel")
For i as integer = 0 To P.GetUpperBound(0)
EApp = Ctype(Marshal.GetActiveObject(P.ID), Excel.Application)
' application check here
Next
"
to find the second, third etc. application also.
Is there any idea?
Thank you
Carsten
|
|
|
|
|
Hi
I am having some issues with installation / deployment of a vb.net project, which are because of some OCM & Activex components
- I had originally made most of the application in vb6
- Then we converted the codes to vb.2005 express
- Then some more development was done
- Now the issue is that when we try to install the application on a client’s machine (which dose not have VB6 installed), the application dose not work
- After investing some time we found out that the issue is due to non availability of vb6 COM & Activex components
How do we add the reference of these COM component to the setup and export the DLL’s with it
Regards
Nishkarsh
-- modified at 6:09 Tuesday 13th November, 2007
|
|
|
|
|
Just add assembly in your setup project and register it on relative path. Hope this works
Regards
Pankaj Joshi
|
|
|
|
|
How can I access the registry location 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrnetVersion\App Paths'. I have a application loaded and the exe name is 'mspview.exe'. I want to find out the location of the exe where it has been loaded. so I need to access the registry path -'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrnetVersion\App Paths\mspview.exe'. If this key exists then that means the application has been loaded in the system. And if the application has been loaded then I want to find the subkey 'Path' from which I can get the location where it has been loaded. Please Help
Thanks in advance.
Sekhar
|
|
|
|
|
It always makes me laugh when the first google hit is an article on code project
http://www.google.com.au/search?sourceid=navclient&ie=UTF-8&rlz=1T4ADBS_enAU225AU226&q=vb%2enet+registry[^]
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How can I speed up the drop down of a combo box inside a datagridview column. when I click on the drop down button to open up the list in the combobox type column of the datagridview, it takes 2-3 seconds to drop down. Can anybody suggest what might be the problem ?
Thanks in Advance.
Sekhar
|
|
|
|
|
Too many items ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have a datagridview control in which i have got a column of type DataGridViewComboBoxColumn. I populate this column's combo when I load the form. But while running if i click on the column's drop down button, so that I can view the list of data in the combobox of the column, it takes 2-3 seconds to show me the list. How can I speed up this drop down of the list so that I can make the application faster.
Thanks in Advance.
Sekhar
|
|
|
|
|
Hi all
Now a can read text file line by line its come like this
in text box
2000121212 John 1980-02-01
but i want to insert them in table in three column
col1 =customerid , col2 = name , col3 = berth date
-- modified at 6:00 Tuesday 13th November, 2007
|
|
|
|
|
If it comes like that, odds are you want to read it as XML. Odd that the XML is not better formed. Looks like you want to use the string.Split method and either split on tab, or if that's lots of spaces, just get the items in the array that are not blank.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dear:Christian Graus
that file its come in text file like report that contents introduction about report then line of column name then data like this
1Report : SIBP5000 date 2007/11/10
-------------------------------------------------------------------------
iduser Name Created Exp Dte
-------------------------------------------------------------------------
2111001100 john 2007/08/08 2008/08/08
2111000000 scot 2007/08/08 2008/08/08
2555555500 jany 2007/08/08 2008/08/08
2113333100 john 2007/05/08 2008/05/08
i want to do a programm by using VB.net that let me read this report and store
them in table content thats data only >>>>
so i use readstream mouthed to read this data line by line
Q: how to split that line so i can but data in table?
Q2:how to insert them in table?
|
|
|
|
|
1 - the split method on the string class
2 - depends, what sort of table ? The web abounds with examples on how to connect to the various databases that exist.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Can you give me examples about split method in this line
200041511 john 1899/02/02
how to split 9 digit for idno then after 9 digit split 15 digit for name then after 9+15=24 split 10 digit for berth date ?
|
|
|
|