|
Go to the property, mark all the text with the mouse and press DELETE.
It's strange, but it's this way...
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
After many hours of battling with others sample code and sifting through countless message board posts I believe I have managed to come up with a fairly functional and stable encryption and decryption class that utilises multiple encryption methods.
The code is shown below and a sample call would look something like
Dim Crypto As New Crypto(Crypto.Providers.DES)
Dim Encrypted as string = Crypto.Encrypt("Test String", "Keystring")
Dim Decrypted as string = Crypto.Decrypt(Encrypted , "Keystring")
‘Crypto class
Imports System.Security.Cryptography
Imports System.IO
Imports System.Text
'SymmCrypto is a wrapper of System.Security.Cryptography.SymmetricAlgorithm classes
'and simplifies the interface. It supports customized SymmetricAlgorithm as well.
'Original Code from Frank Fang
'Revised by Jerome Howard to remove Bad Data errors, create seperate CryptoIV and
'use the maximum legal keysize for each encryption algorithm
Public Class Crypto
'256 Bit IV Key that is truncated when a smaller keys are required
Private bytIV() As Byte = _
{12, 241, 10, 21, 90, 74, 11, 39, 9, 91, 45, 78, 189, 211, 133, 62, 121, 22, 101, 34, 90, 74, 121, 39, 93, 9, 45, 78, 1, 211, 33, 162}
'Supported .Net intrinsic SymmetricAlgorithm classes.
Public Enum Providers
DES
RC2
Rijndael
End Enum
Private _CryptoService As SymmetricAlgorithm
'Constructor for using an intrinsic .Net SymmetricAlgorithm class.
Public Sub New(ByVal NetSelected As Providers)
Select Case NetSelected
Case Providers.DES
_CryptoService = New DESCryptoServiceProvider()
Case Providers.RC2
_CryptoService = New RC2CryptoServiceProvider()
Case Providers.Rijndael
_CryptoService = New RijndaelManaged()
End Select
End Sub
'Constructor for using a customized SymmetricAlgorithm class.
Public Sub New(ByVal ServiceProvider As SymmetricAlgorithm)
_CryptoService = ServiceProvider
End Sub
'Depending on the legal key size limitations of a specific CryptoService provider
'and length of the private key provided, padding the secret key with a character
'or triming it to meet the legal size of the algorithm.
Private Function GetLegalKey(ByVal Key As String) As Byte()
'key sizes are in bits
Dim sTemp As String
If (_CryptoService.LegalKeySizes.Length > 0) Then
Dim maxSize As Integer = _CryptoService.LegalKeySizes(0).MaxSize
If Key.Length * 8 > maxSize Then
sTemp = Key.Substring(0, (maxSize / 8))
ReDim Preserve bytIV((maxSize / 8) - 1)
Else
Dim moreSize As Integer = _CryptoService.LegalKeySizes(0).MinSize
Do While (Key.Length * 8 > moreSize)
moreSize += _CryptoService.LegalKeySizes(0).SkipSize
Loop
ReDim Preserve bytIV(moreSize / 8)
sTemp = Key.PadRight(moreSize / 8, "X")
End If
Else
sTemp = Key
ReDim Preserve bytIV(Key.Length)
End If
'convert the secret key to byte array
Return ASCIIEncoding.ASCII.GetBytes(sTemp)
End Function
Public Function Encrypt(ByVal Source As String, ByVal Key As String) As String
Dim bytIn As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(System.Web.HttpUtility.UrlEncode(Source))
Dim ms As MemoryStream = New MemoryStream()
'set the keys
_CryptoService.Key = GetLegalKey(Key)
_CryptoService.IV = bytIV
'create an Encryptor from the Provider Service instance
Dim encrypto As ICryptoTransform = _CryptoService.CreateEncryptor()
'create Crypto Stream that transforms a stream using the encryption
Dim cs As CryptoStream = New CryptoStream(ms, encrypto, CryptoStreamMode.Write)
'write out encrypted content into MemoryStream
cs.Write(bytIn, 0, bytIn.Length)
cs.FlushFinalBlock()
cs.Close()
Dim bytOut() As Byte = ms.ToArray()
ms.Close()
Return Convert.ToBase64String(bytOut) 'convert into Base64 so that the result can be used in xml
End Function
Public Function Decrypt(ByVal Source As String, ByVal Key As String) As String
'convert from Base64 to binary
Dim bytIn As Byte() = System.Convert.FromBase64String(Source)
Dim ms As MemoryStream = New MemoryStream(bytIn)
Dim bytKey() As Byte = GetLegalKey(Key)
Dim bytTemp(bytIn.Length) As Byte
'set the private key
_CryptoService.Key = bytKey
_CryptoService.IV = bytIV
'create a Decryptor from the Provider Service instance
Dim encrypto As ICryptoTransform = _CryptoService.CreateDecryptor()
'create Crypto Stream that transforms a stream using the decryption
Dim cs As CryptoStream = New CryptoStream(ms, encrypto, CryptoStreamMode.Read)
Try
'read out the result from the Crypto Stream
cs.Read(bytTemp, 0, bytTemp.Length)
cs.FlushFinalBlock()
ms.Close()
cs.Close()
Catch
End Try
Return System.Web.HttpUtility.UrlDecode(Encoding.ASCII.GetString(bytTemp))
End Function
End Class
|
|
|
|
|
Simple question that has me stumped.
Help!
Chris
|
|
|
|
|
Have a look at the article "Registry handling with .NET" by S Nishant in this site (www.codeproject.com/dotnet/csregistry01.asp).
The VB.NET equivalent is virtually identical.
Imports Microsoft.Win32.Registry
Imports Microsoft.Win32.RegistryKey
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rKey As Microsoft.Win32.RegistryKey
Dim rKey1 As Microsoft.Win32.RegistryKey
rKey = Microsoft.Win32.Registry.LocalMachine
rKey1 = rKey.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion")
ListBox1.Items.Add("RegisteredOwner :- " + rKey1.GetValue("RegisteredOwner"))
ListBox1.Items.Add("RegisteredOrganization :- " + rKey1.GetValue("RegisteredOrganization"))
ListBox1.Items.Add("ProductName :- " + rKey1.GetValue("ProductName"))
ListBox1.Items.Add("CSDVersion :- " + rKey1.GetValue("CSDVersion"))
ListBox1.Items.Add("SystemRoot :- " + rKey1.GetValue("SystemRoot"))
rKey1.Close()
End Sub
HTH
Andy
|
|
|
|
|
Heya - I also had a bit of trouble with the registry. I can modify it easy enough but I can't get it to refresh without restarting the computer. Is there some way to force Windows to reload the registry without restarting?
Thanks
Nic R
------------------------------------------
I beat the internet - the end guy is hard.
|
|
|
|
|
|
plz help me with the Input Validation with textbox in VB.NET?
ex : I wanted input masking to be applied on a textbox for that I addedd MaskEdBox Control in Toolbox and tried with that. But still after running the project nothing happens.
plz help me with input validation in textbox with VB.NET
--waiting for a quick reply
|
|
|
|
|
drmzunlimited wrote:
plz help me with input validation in textbox with VB.NET
What part of this are you actually stuck on???
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
How do I display an mpeg or avi file on a form? Thanks for any help.
|
|
|
|
|
If this is for VB6, just use the 'Windows Media Player' ActiveX. To insert it in VB, go to the menu Project->Components, then select the 'Windows Media Player', then OK.
This will add a component that you can put on your form. Then, go through the properties of this component to load your movie.
Hope this helps !
Jerome
|
|
|
|
|
is there a simple way to re-interpret the enter key as the tab key in dialogs?
in c++ there is a PreTranslateMsg() function which you can use to listen for an enter key-press, then resend the key-press as a tab key.. is there anything like this for vb?
thanks for any suggestions!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
use the KeyDown Event for each tab-enabled control. of course,this way, you have a lot of coding to do but it's the only way that i know
|
|
|
|
|
my VB6 application which calls and uses Excel works fine in Windows NT,2K and XP , but experiences problems when running on Windows 98. The system hangs and the message "System is dangerously low on resources" appear. I am assuming that this happen because Win98 does not have very secure Resource Management compared to NT based OS. Does anyone have any idea how to make my app work in Win98 ?
|
|
|
|
|
I'm trying to use drag & drop with a multiselection. I would like to copy the listview selected items on an other listview. I tried that :
<br />
Private Sub lstAllRole_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstAllRole.MouseDown<br />
lstAllRole.DoDragDrop(lstAllRole.SelectedItems, DragDropEffects.Copy)<br />
End Sub<br />
<br />
Private Sub lstRole_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstRole.DragEnter<br />
' If e.Data().GetDataPresent("System.Windows.Forms.ListView.ListViewItemCollection", False) Then<br />
If e.Data().GetDataPresent(lstAllRole.SelectedItems.GetType().ToString(), False) Then<br />
e.Effect() = DragDropEffects.Copy<br />
Else<br />
e.Effect() = DragDropEffects.None<br />
End If<br />
End Sub<br />
<br />
Private Sub lstRole_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstRole.DragDrop<br />
Dim obj As ListViewItem<br />
Dim objCol As Object<br />
<br />
<br />
For Each obj In e.Data.GetData(lstAllRole.SelectedItems.GetType().ToString(), False)<br />
lstRole.Items.Add(obj)<br />
Next<br />
End Sub<br />
The drag & drop works but not the copy. Does someone already do it ?
Thanks
|
|
|
|
|
How do i declare & use "HttpSendRequest" in VB.NET
Thanks in advance
|
|
|
|
|
Vipul,
You have now sent me three email messages asking how to do this. As I have previously pointed out, I do not reply to questions sent by email unless they relate to an article or code sample I have published.
You have posted the question to several different forums. If someone knows the answer, they will no doubt post a response. If you continue to email this question to me, I will report you for sending Spam.
Richard
|
|
|
|
|
Hi,
I am trying to access password and aliases or for that matter every thing related to microsoft exchange users i am able to retrieve only usernames using mapi.session object,
Please help in retrieving other things if any body has code plesae post it here.
I have tried using ADSI also.
Thanks,
Amit Gupta
|
|
|
|
|
Hello guys/gals,
Any idea how can i check printer status in vb.net. I am trying return a boolean value if printer is out of paper. Thank you in advance for your help. Cheers and have a good weekend.
Zulfikar Ali
|
|
|
|
|
hi ppl!!1
i am faing problems.. regarding the registration of crystal reports in vb.net
|
|
|
|
|
how to use print previiew control or how to use that to print a form in VB.NET?
or to print a document in VB.net using Print Preview control?
bye
--Aakash
|
|
|
|
|
like we had data reports in VB6 so what do we do for making reports in Vb.net
what to do?
--aakash
|
|
|
|
|
drmzunlimited wrote:
what to do?
Unfortunately Crystal Reports [^] has integrated with VS.NET. There is a lot of nice things about Crystal Reports, however they tend to have a lot of design flaw in previous versions of their software (e.g. 8.5).
Nick Parker
The greatest lesson in life is to know that even fools are right sometimes. - Winston Churchill
|
|
|
|
|
does anybody knows how to import data from excel file and store it in a Microsoft Access Database Table.
plz help me with this.
thnx
Aakash
|
|
|
|
|
look up the Access command:
docmd.tansfertext
|
|
|
|
|
does anybody knows how to import data from excel file and store it in a Microsoft Access Database Table.
plz help me with this.
thnx
Aakash
|
|
|
|