Click here to Skip to main content
15,895,423 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to find mysql table field is empty ? Pin
Biplob Singha Shee19-Jul-13 22:42
Biplob Singha Shee19-Jul-13 22:42 
AnswerRe: How to find mysql table field is empty ? Pin
Biplob Singha Shee20-Jul-13 0:32
Biplob Singha Shee20-Jul-13 0:32 
QuestionERROR When I Show Openfiledialog.ShowDialog() Pin
Sang Nguyen Minh19-Jul-13 8:44
Sang Nguyen Minh19-Jul-13 8:44 
SuggestionRe: ERROR When I Show Openfiledialog.ShowDialog() Pin
Richard Deeming19-Jul-13 8:59
mveRichard Deeming19-Jul-13 8:59 
AnswerRe: ERROR When I Show Openfiledialog.ShowDialog() Pin
Richard MacCutchan19-Jul-13 22:19
mveRichard MacCutchan19-Jul-13 22:19 
AnswerRe: ERROR When I Show Openfiledialog.ShowDialog() Pin
Dave Kreskowiak20-Jul-13 2:57
mveDave Kreskowiak20-Jul-13 2:57 
GeneralRe: ERROR When I Show Openfiledialog.ShowDialog() Pin
Sang Nguyen Minh20-Jul-13 6:21
Sang Nguyen Minh20-Jul-13 6:21 
QuestionEncryption AES256 Trouble.. Pin
markapk18-Jul-13 7:56
markapk18-Jul-13 7:56 
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.
AnswerRe: Encryption AES256 Trouble.. Pin
Kenneth Haugland18-Jul-13 20:09
mvaKenneth Haugland18-Jul-13 20:09 
GeneralRe: Encryption AES256 Trouble.. Pin
markapk18-Jul-13 22:04
markapk18-Jul-13 22:04 
GeneralRe: Encryption AES256 Trouble.. Pin
Matty2229-Jul-13 19:16
Matty2229-Jul-13 19:16 
GeneralRe: Encryption AES256 Trouble.. Pin
markapk29-Jul-13 20:21
markapk29-Jul-13 20:21 
GeneralRe: Encryption AES256 Trouble.. Pin
markapk8-Aug-15 11:41
markapk8-Aug-15 11:41 
QuestionHow to get ListView item Icons ? Pin
Biplob Singha Shee17-Jul-13 7:34
Biplob Singha Shee17-Jul-13 7:34 
AnswerRe: How to get ListView item Icons ? Pin
Richard MacCutchan17-Jul-13 21:20
mveRichard MacCutchan17-Jul-13 21:20 
AnswerRe: How to get ListView item Icons ? Pin
TnTinMn18-Jul-13 11:36
TnTinMn18-Jul-13 11:36 
QuestionHow To Populate Data In Another Form Of Display Pin
12345_abcde15-Jul-13 3:36
12345_abcde15-Jul-13 3:36 
AnswerRe: How To Populate Data In Another Form Of Display Pin
Eddy Vluggen18-Jul-13 6:38
professionalEddy Vluggen18-Jul-13 6:38 
QuestionVB.net connect to Access with master and child table Pin
dmtp10-Jul-13 11:30
dmtp10-Jul-13 11:30 
AnswerRe: VB.net connect to Access with master and child table Pin
Bernhard Hiller14-Jul-13 21:51
Bernhard Hiller14-Jul-13 21:51 
Questionhow to capture the url of a popup window. Pin
rshaheen9-Jul-13 5:24
rshaheen9-Jul-13 5:24 
AnswerRe: how to capture the url of a popup window. Pin
Dave Kreskowiak9-Jul-13 5:34
mveDave Kreskowiak9-Jul-13 5:34 
GeneralRe: how to capture the url of a popup window. Pin
rshaheen9-Jul-13 6:03
rshaheen9-Jul-13 6:03 
GeneralRe: how to capture the url of a popup window. Pin
Dave Kreskowiak9-Jul-13 6:30
mveDave Kreskowiak9-Jul-13 6:30 
AnswerRe: how to capture the url of a popup window. Pin
Brisingr Aerowing14-Jul-13 12:22
professionalBrisingr Aerowing14-Jul-13 12:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.