Re: Problem with Image Loading - WeOnlyDo Discussion board

Re: Problem with Image Loading (General questions)

by wodDrazen, Monday, May 22, 2006, 10:17 (6760 days ago) @ wodSupport

Here is how I did it in VB.NET:

Encypt file on one machine:
--------------------------------------------------------
Public Class Form1

Dim WithEvents crypt1 As WODCRYPTCOMLib.wodCryptCom

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim srcfile As New WODCRYPTCOMLib.FileBlob
Dim destfile As New WODCRYPTCOMLib.FileBlob

crypt1 = New WODCRYPTCOMLib.wodCryptCom
crypt1.Optimized = True
crypt1.Type = WODCRYPTCOMLib.CryptoTypes.AES256
crypt1.SecretKey = weonlydo

srcfile.Filename = z:\image.jpg
destfile.Filename = c:\decimage.jpg

crypt1.Encrypt(srcfile, destfile)
MsgBox( Encyption Complete )
End Sub
End Class
--------------------------------------------------------


Decrypt file to MemBlob on other machine and load picture from MemBlob in PictureBox:

--------------------------------------------------------
Public Class Form1

Dim WithEvents crypt1 As WODCRYPTCOMLib.wodCryptCom
Dim d As System.Array

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim srcfile As New WODCRYPTCOMLib.FileBlob
Dim destmem As New WODCRYPTCOMLib.MemBlob

crypt1 = New WODCRYPTCOMLib.wodCryptCom
crypt1.Type = WODCRYPTCOMLib.CryptoTypes.AES256
crypt1.SecretKey = weonlydo
crypt1.Optimized = True

srcfile.Filename = c:\decimage.jpg

crypt1.Decrypt(srcfile, destmem)
d = destmem.ToArray

MsgBox( Decryption Complete )
End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim s As System.IO.Stream
Dim i As Int32

s = New System.IO.MemoryStream(d.Length)

For i = 1 To d.Length
s.WriteByte(d(i))
Next

PictureBox1.Image = Image.FromStream(s)
End Sub
End Class
--------------------------------------------------------

Hope this helps.


Regards,
Drazen


Complete thread: