|
You cannot create, show, nor touch in any way any UI items on anything other than the startup thread.
Creating a thread to show a modal dialog? That's completely pointless...
|
|
|
|
|
|
Okay so I'm very new to Encryption, I have done a lot of research via Google and I cannot find an answer to my questions, so either I'm totally not understanding this or .. okay I don't get it. Maybe someone here can help:
1. I need to generate a 256 bit Public / private key pair and store them for later use
2. I need to be able to encrypt using a stored private key
3. I need to be able to decrypt with a stored public key
(2 and 3) I was unable to find some example where keys are loaded from a file to be used, they all generated the keys new for each encryption.
And maybe someone can explain to me the way to encrypt and decrypt large files about 5 mb each with a loop, as the padding issue seems to have issues. Im trying to break up very lage files into 5mb chunks and encrypt them, then later decrypt them back into the whole file.
To me all this seems to be simple but I am at a loss when Googling this info as it all seems to derive their solutions with so many different providers and methods, and I just don't fully understand whats going on.
So the bottom like is : How can I create a Public/Private Key pair that is AES256 compliant (If that's even right) but I need a 256 bit PKI , then store them in a file to be used in the encrypt decrypt system. Can this be done without using a pass-phrase?
Again I have gotten to the point of encrypting with the use of some examples..
Here is my Generate keys function which works but im not sure if it is creating keys that I need (256)
<pre lang="vb">
Private Shared Sub Keys(publicKeyFileName As String, privateKeyFileName As String)
Dim cspParams As CspParameters = Nothing
Dim rsaProvider As RSACryptoServiceProvider = Nothing
Dim publicKeyFile As StreamWriter = Nothing
Dim privateKeyFile As StreamWriter = Nothing
Dim publicKey As String = ""
Dim privateKey As String = ""
Try
cspParams = New CspParameters()
cspParams.ProviderType = 1
cspParams.Flags = CspProviderFlags.UseArchivableKey
cspParams.KeyNumber = CInt(KeyNumber.Exchange)
rsaProvider = New RSACryptoServiceProvider(cspParams)
publicKey = rsaProvider.ToXmlString(False)
publicKeyFile = File.CreateText(publicKeyFileName)
publicKeyFile.Write(publicKey)
privateKey = rsaProvider.ToXmlString(True)
privateKeyFile = File.CreateText(privateKeyFileName)
privateKeyFile.Write(privateKey)
Catch ex As Exception
Console.WriteLine("Exception generating a new key pair! More info:")
Console.WriteLine(ex.Message)
Finally
' Do some clean up if needed
If publicKeyFile IsNot Nothing Then
publicKeyFile.Close()
End If
If privateKeyFile IsNot Nothing Then
privateKeyFile.Close()
End If
End Try
</pre>
Here is the encryption routine, again i have no idea how to have it use MY key and no password:
<pre lang="vb">
Dim rk As Byte() = Nothing
Dim riv As Byte() = Nothing
Dim salt As Byte() = System.Text.Encoding.ASCII.GetBytes("System.Text.Encoding.ASCII.GetBytes")
Dim pb As New PasswordDeriveBytes("somepassword", salt)
Dim origName As String = TmpStore & "\" & f.ToString
Dim encName As String = origName & ".enc"
cryptoKey = pb.GetBytes(32) : cryptoIV = pb.GetBytes(16)
Try
crm.EncryptData(origName, encName, cryptoKey, cryptoIV)
Dim fi As New FileInfo(origName) : Dim fi2 As New FileInfo(encName)
If (fi.Attributes And FileAttributes.[ReadOnly]) = FileAttributes.[ReadOnly] Then fi.Attributes = fi.Attributes And Not FileAttributes.[ReadOnly]
fi2.CreationTime = fi.CreationTime : fi2.LastWriteTime = fi.LastWriteTime
fi2.Attributes = FileAttributes.[ReadOnly] Or FileAttributes.Archive
File.Delete(origName)
Catch ex As CryptographicException
MessageBox.Show(ex.Message)
Catch ex As IOException
MessageBox.Show(ex.Message)
Catch ex As UnauthorizedAccessException
'i.e. readonly
MessageBox.Show(ex.Message)
End Try
</pre>
Any help is greatly appreciated. Sorry for my lack of understanding, but I am sort of under a deadline and I just cant seem to pull it off with the information out there.
|
|
|
|
|
|
Also this is not a commercial project, this is an internal project I am working on with a few people for our own personal use, mostly experimental.
I've seen that code before, it is very similar to a lot of code out there. My Issue with it is HOW to I use a Public Key of My Choosing to encrypt and Private to decrypt. Also how do I avoid using a password, and it is AES256 compliant?
|
|
|
|
|
Public key cryptography is totally separate from AES
AES is a symmetric algorithm (The person decrypting needs to share a key with the person encrypting)
Symmetric algorithms include things like RC5, AES, 3DES
Public key cryptography refers to asymmetric algorithms. (Stuff encrypted with a public key can be decrypted with a private key and stuff encrypted with the private key can be descrypted with the public key)
Asymmetric/public key algorithms include RSA, ECC.
|
|
|
|
|
Ya, I should have closed this, I got it figured out...
|
|
|
|
|
|
Hi,
I would like to get filenames from a directory and populate its name and icons in a listview.
I tried for the filename and succeded.
Private Sub PopulateData()
Dim FilePath As String = Application.StartupPath & "\users\"
Dim ContentItem As String = Dir(FilePath & "*.dat")
ListView1.Items.Clear()
If ContentItem = "" Then
MsgBox("No users found.")
End If
Do Until ContentItem = ""
ListView1.Items.Add(ContentItem)
ContentItem = Dir()
Loop
End Sub
and I am populating the listview in form loading event.
Private Sub FormCreateUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PopulateData()
End Sub
"users" is a folder from where I want to get the filename details.
But I want to get the file icons also and I don't know how to do this.
Please help.
modified 17-Jul-13 13:41pm.
|
|
|
|
|
Files do not have icons, that is just a mechanism used by Windows Explorer to help provide visual identification of different types of files. You could get the icons out of explorer, or creatre your own, and save them in your program then use the same criteria to add them to your listview. However, since you are only searching for files with the .dat extension there seems little point in having the same icon on each entry.
Use the best guess
|
|
|
|
|
|
Hi, i have a database with the following details:
SCHOOL CAMPUS ADMINNO MODULECODE MODULEGRP
SEG AMK 100810R EG3932 EG3932-G1
SEG AMK 100810R EG3933 EG3933-G1
SEG AMK 101427Y EG3901 EG3901-G1
SEG AMK 101427Y EG3902 EG3902-G1
SEG AMK 101427Y EGS650 EGS650-G1
SEG AMK 103852S EG3901 EG3901-G1
SEG AMK 103852S EG3904 EG3904-G1
now i managed to get distinct students(adminno), modulecode(subject) populate in a datagrid
also, module-students in dgv which looks like:
EG1001 ---- Student 1
----------- Student 2
----------- Student 3
EG1002 ---- Student 2
----------- Student 4
But now i want to achieve:
Modulecode --- ModuleGrp ---- numberofstudents ---- students adminno
EG3932 ------- G1 ----------- 58 ------------------ 111411H 11253U 178292I...
Can anyone advice how can i go about achieving this?
Listview? or multi Line textbox? or other choices?
using vb.net, SQL commands with OleDB to retrieve data.
Thanks in advance!
|
|
|
|
|
12345_abcde wrote: Can anyone advice how can i go about achieving this? Listview? or multi Line textbox? or other choices? A DataGridView
Roughly the same code as the previous exercise, but a different query. A complex one at that, since your data doesn't look normalized. And from which table would "NumberOfStudents" come? Not the one from the example-table.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi all,
I'm a newbie at VB.net,
I want connect to access via VB.net and manager two table with a relation type "master-child",
Master table named "Book" consists of three columns: BookID [AutoNumber], Author [Text], Description [Text],
Child table named "Chapter" with three columns: ChapterID [AutoNumber], BookID [Number], Title [Text],
Then I create an application VB.net that has one main window using a dataset with two table Book and Chapter. I make a relation between them, from BookID in the table Chapter to BookID in the master table. I use a databindingsource to manager them, the table Book is displayed by a form detail, the Chapter by a datagridview. When I delete a row in Book-table, I also want delete all chapter located it. I tried to use Tableadapter but the chapters were not deleted.
Help me,
|
|
|
|
|
When you create / edit the table definitions, make sure that you set referential integrity with "OnDeleteCascade". Then the database will handle that.
|
|
|
|
|
im working on a project at the moment and i am facing a critical problem.
The tool that i have created using vb.net vs 2010 ultimate opens a "webbrowser" inside a windows form
this webbrowser displays a combination of not static banners from another server.
These banners hav an onclick event that opens a webpage.
For example : if you click on the puma banner, IE browser opens the official puma page.
My problem is that when it is opening with IE, no problem at all. The page is opening and loading normally.
whenever i use the "Process.Start(e.ToString())" to open it with the default browser,the default browser launches but with
url: System.ComponentModel.CancelEventArgs
the function is so simple to write but somehow, i am not able to assign a e.url.tostring to the process.start knowing that im using it in the newwindow event.
in the newwindow event, if i change the definirion of e as System.ComponentModel.CancelEventArgs to e as System.Windows.Forms.WebBrowserNavigatingEventArgs then it will always open with IE
i have been trying every single solution i could think of or found online so far and still ... it either opens with IE perfectly (which is not what i want- should be in default browser) Or the default browser launches onclick to the homepage of the browser.
Is there any way to record the URL called in the popup IE window and save it somewhere to be able to browse it using the process.start Or is there another way to do that.
Im kinda getting frustrated from this already
Your help will be highly appreciated
Roy
|
|
|
|
|
You're launching the CancelEventArgs object (converted to a string). You're not supplying a URL to launch. What event are you handling that you've put this Process.Start code into?
|
|
|
|
|
yes i know i am not passing a url through.
Thats my exact question .... how can i catch the url of the window that is opening in IE so i can launch it from anywhere i want to !
Regarding the events, i am stopping the Ie from opening via e.cancel = true in the newwindow event
and then i tried on the navigating to run process.start(e.url.tostring())
|
|
|
|
|
Considering CancelEventArgs doesn't have a URL property, what you're doing isn't going to work.
You can try to handle the NewWindow or Navigating events of the WebBrowser control. I suggest reading up on those events to see exactly what they do, what argument they expose and what the properties of those arguments are before you proceed.
|
|
|
|
|
Public Delegate Sub NewWindowExtendedEventHandler(ByVal sender As Object, ByVal e As NewWindowExtendedEventArgs)
Public Class NewWindowExtendedEventArgs : CancelEventArgs
Private url As Uri
Public ReadOnly Property Url As Uri
Get
Return url
End Get
End Property
Public Sub New(ByVal url As Uri)
Me.url = url
End Sub
End Class
Public Class ExtendedWebBrowser
Inherits WebBrowser
Private Class WebBrowserExtendedEvents
Inherits System.Runtime.InteropServices.StandardOleMarshalObject
Implements DWebBrowserEvents2
Private browser As ExtendedWebBrowser
Public Sub New(browser As ExtendedWebBrowser)
Me.browser = browser
End Sub
Public Sub NewWindow3(pDisp As Object, ByRef cancel As Boolean, ByRef flags As Object, ByRef urlContext As String, ByRef url As String) Implements ExtendedWebBrowser.DWebBrowserEvents2.NewWindow3
Dim e As New NewWindowExtendedEventArgs(New Uri(url))
browser.OnNewWindowExtended(e)
cancel = e.Cancel
End Sub
End Class
<ComImport> _
<Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D")> _
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)> _
<TypeLibType(TypeLibTypeFlags.FHidden)> _
Private Interface DWebBrowserEvents2
<DispId(273)> _
Sub NewWindow3(<InAttribute, MarshalAs(UnmanagedType.IDispatch)> pDisp As Object, <InAttribute, OutAttribute> ByRef cancel As Boolean, <InAttribute> ByRef flags As Object, <InAttribute, MarshalAs(UnmanagedType.BStr)> ByRef urlContext As String, <InAttribute, MarshalAs(UnmanagedType.BStr)> ByRef url As String) Implements ExtendedWebBrowser.DWebBrowserEvents2.NewWindow3
End Interface
Public Event NewWindowExtended As NewWindowExtendedEventHandler
Private cookie As AxHost.ConnectionPointCookie
Private wevents As WebBrowserExtendedEvents
Protected Overrides Sub CreateSink()
MyBase.CreateSink()
wevents = New WebBrowserExtendedEvents(Me)
cookie = New AxHost.ConnectionPointCookie(Me.ActiveXInstance, wevents, GetType(DWebBrowserEvents2))
End Sub
Protected Overrides Sub DetachSink()
If cookie IsNot Nothing Then
cookie.Disconnect()
cookie = Nothing
End If
MyBase.DetachSink()
End Sub
Protected Overridable Sub OnNewWindowExtended(e As NewWindowExtendedEventArgs)
RaiseEvent NewWindowExtended(Me, e)
End Sub
End Class
Hope this helps. I just converted this from the C# code in #Develop. It allows for getting the URL of the event.
brisingr_aerowing@Gryphon-PC $ rake in_the_dough
Raking in the dough
brisingr_aerowing@Gryphon-PC $ make lots_of_money
Making lots_of_money
|
|
|
|
|
Hi all, I want to create a Windows service that detect system datetime change and as soon as it detects the change, it gives a message "System DateTime has been changed".
Public Class CltChk
Protected Overrides Sub OnStart(ByVal args() As String)
End Sub
Protected Overrides Sub OnStop()
End Sub
Private Sub CheckDateTimeClock()
Dim SysTime As Date = Date.Now
Dim CurrentHour As Integer = SysTime.Hour
Dim CurrentMinute As Integer = SysTime.Minute
Dim CurrentSecond As Integer = SysTime.Second
Dim CurrentMilliSecond As Integer = SysTime.Millisecond
End Sub
End Class
I created a windows service but I don't know how to start.
Please HELP me.
modified 9-Jul-13 8:36am.
|
|
|
|
|
Member 7815124 wrote: a Windows service ... it gives a message "System DateTime has been changed".
A Windows service cannot interact with the desktop, so it's not going to be able to display a message to the user. There might not even be a user logged in when the system time changes.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your quick answer.
So what am I to do ? Creating a windows process that runs in background ? What should be the code ?
I have written something please check it.....
Public Class Form1
Dim iDate As DateTime = DateTime.Now
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim iDateNow As DateTime = DateTime.Now
If iDateNow <> iDate Then
MsgBox("Date Time Change Detected.")
End If
End Sub
End Class
Is the above code OK ? How should I run it like a process ?
modified 9-Jul-13 7:53am.
|
|
|
|
|
That code is going to pop up a message every second. If you leave it running, it will fill your screen with messages, and eventually exhaust all system resources.
What are you actually trying to achieve?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, First I should tell you that I am not getting any message running this code(I do not know why? is it that I am not using a loop?).
Secondly and most important thing is I am trying to create something that detects System Date Time change and give a message to the user. This program will be connected to my main program i.e. if this program/process is closed then the main program will be closed automatically.
My main program contains a piece of code that writes install date, License period and last use date in the registry. If the user try to manipulate the system date and time my main program will not open (Although the idea or the code is not fullproof)
So I want to warn user through the detection of dateTime change that, to get back the last date time otherwise the program will not run.
|
|
|
|