Encrypt/Decrypt Image Files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean Christophe Avard

    Encrypt/Decrypt Image Files

    Hi! I am designing an application wich comes with image file. These images
    are copyrighted and they have to be accessible only from within the
    application. At first, I tought I was going to store them in a database, but
    since there will be much more than 2go, I'm going to need multiple database,
    and it's no good for CPU performance...

    I read about encrypting picture instead of storing them in a DB. But I only
    found thing about string encryption... Has anyone of you ever had to
    encrypt/decrypt image file? Anyone could point me a good tuorials or website
    or anything???

    Thank you, your help is really appreciated!

    Jean Christophe Avard!


  • m.posseth

    #2
    Re: Encrypt/Decrypt Image Files


    yep me ,,,,,

    even better i have a +- 3 gb of pictures and had to ship them on a DVD to
    our customers in a somehow protected way
    then i found the following solution

    i was also searching for a way to group the picture files together in a
    sort kind of library

    then i found the solution in a nice opensource project
    ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
    compiled binary , source in C# with sharpdevelop project file , and
    examples ) and explored the classes

    i found that it is possible to create password protected library`s with
    this dll , it works flawless for me i compress multiple files to one
    password protected lib when i need to display the file i open the lib i
    search the entry in the lib load it to a memstream and send it directly to
    a picture box


    to create a protected lib

    Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button2.Click
    Dim strDirnames() As String = Directory.GetDi rectories(txtSo urceDir.Text)

    For Each strDirname As String In strDirnames

    Dim astrFileNames() As String = Directory.GetFi les(strDirname)

    Dim objCrc32 As New Crc32

    Dim strmZipOutputSt ream As ZipOutputStream

    strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\" &
    Path.GetFileNam e(strDirname) & ".cp"))

    strmZipOutputSt ream.Password = "your own prefered password here"

    strmZipOutputSt ream.SetLevel(6 )

    REM Compression Level: 0-9

    REM 0: no(Compression)

    REM 9: maximum compression

    Dim strFile As String

    For Each strFile In astrFileNames

    Dim strmFile As FileStream = File.OpenRead(s trFile)

    Dim abyBuffer(strmF ile.Length - 1) As Byte

    strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)

    Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)

    objZipEntry.Dat eTime = DateTime.Now

    objZipEntry.Siz e = strmFile.Length

    strmFile.Close( )

    objCrc32.Reset( )

    objCrc32.Update (abyBuffer)

    objZipEntry.Crc = objCrc32.Value

    strmZipOutputSt ream.PutNextEnt ry(objZipEntry)

    strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)

    Next

    strmZipOutputSt ream.Finish()

    strmZipOutputSt ream.Close()



    Next




    MessageBox.Show ("Operation complete")

    End Sub

    to extract a entry to a stream

    Private Overloads Function Unzip(ByVal strSource As String, ByVal
    strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean

    If File.Exists(str Source) Then

    Dim ZipStream As ZipInputStream

    Try

    ZipStream = New ZipInputStream( File.OpenRead(s trSource))

    ZipStream.Passw ord = "your own prefered password here"

    Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()

    Dim size As Integer

    Do Until TheEntry Is Nothing

    If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then

    Dim data(1024) As Byte

    newms = New MemoryStream

    Dim bw As New BinaryWriter(ne wms)

    Dim buffer(1024) As Byte

    Dim length As Integer

    Dim dataToRead As Long = TheEntry.Size

    While dataToRead > 0

    length = ZipStream.Read( buffer, 0, 1024)

    bw.Write(buffer , 0, length)

    ReDim buffer(1024) ' Clear the buffer

    dataToRead = dataToRead - length

    End While

    Return True

    End If

    TheEntry = ZipStream.GetNe xtEntry()

    Loop

    Catch e As Exception

    Finally

    ZipStream.Close ()

    End Try

    End If

    End Function


    example to put the stream in a picturebox as a picture

    Dim newms As MemoryStream

    MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))

    PictureBox1.Ima ge = Image.FromStrea m(newms)

    well i hope this helped


    regards

    Michel Posseth




    "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
    news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi! I am designing an application wich comes with image file. These images
    > are copyrighted and they have to be accessible only from within the
    > application. At first, I tought I was going to store them in a database,
    > but since there will be much more than 2go, I'm going to need multiple
    > database, and it's no good for CPU performance...
    >
    > I read about encrypting picture instead of storing them in a DB. But I
    > only found thing about string encryption... Has anyone of you ever had to
    > encrypt/decrypt image file? Anyone could point me a good tuorials or
    > website or anything???
    >
    > Thank you, your help is really appreciated!
    >
    > Jean Christophe Avard!
    >[/color]


    Comment

    • Jean Christophe Avard

      #3
      Re: Encrypt/Decrypt Image Files

      thank you dude!, is this all C# code? and where do I write this? in a text
      file that I call file.DLL ???
      "m.posseth" <michelp@nohaus ystems.nl> wrote in message
      news:uViXxFvuFH A.2504@tk2msftn gp13.phx.gbl...[color=blue]
      >
      > yep me ,,,,,
      >
      > even better i have a +- 3 gb of pictures and had to ship them on a DVD to
      > our customers in a somehow protected way
      > then i found the following solution
      >
      > i was also searching for a way to group the picture files together in a
      > sort kind of library
      >
      > then i found the solution in a nice opensource project
      > ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
      > compiled binary , source in C# with sharpdevelop project file , and
      > examples ) and explored the classes
      >
      > i found that it is possible to create password protected library`s with
      > this dll , it works flawless for me i compress multiple files to one
      > password protected lib when i need to display the file i open the lib i
      > search the entry in the lib load it to a memstream and send it directly
      > to a picture box
      >
      >
      > to create a protected lib
      >
      > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
      > System.EventArg s) Handles Button2.Click
      > Dim strDirnames() As String = Directory.GetDi rectories(txtSo urceDir.Text)
      >
      > For Each strDirname As String In strDirnames
      >
      > Dim astrFileNames() As String = Directory.GetFi les(strDirname)
      >
      > Dim objCrc32 As New Crc32
      >
      > Dim strmZipOutputSt ream As ZipOutputStream
      >
      > strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\" &
      > Path.GetFileNam e(strDirname) & ".cp"))
      >
      > strmZipOutputSt ream.Password = "your own prefered password here"
      >
      > strmZipOutputSt ream.SetLevel(6 )
      >
      > REM Compression Level: 0-9
      >
      > REM 0: no(Compression)
      >
      > REM 9: maximum compression
      >
      > Dim strFile As String
      >
      > For Each strFile In astrFileNames
      >
      > Dim strmFile As FileStream = File.OpenRead(s trFile)
      >
      > Dim abyBuffer(strmF ile.Length - 1) As Byte
      >
      > strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
      >
      > Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
      >
      > objZipEntry.Dat eTime = DateTime.Now
      >
      > objZipEntry.Siz e = strmFile.Length
      >
      > strmFile.Close( )
      >
      > objCrc32.Reset( )
      >
      > objCrc32.Update (abyBuffer)
      >
      > objZipEntry.Crc = objCrc32.Value
      >
      > strmZipOutputSt ream.PutNextEnt ry(objZipEntry)
      >
      > strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)
      >
      > Next
      >
      > strmZipOutputSt ream.Finish()
      >
      > strmZipOutputSt ream.Close()
      >
      >
      >
      > Next
      >
      >
      >
      >
      > MessageBox.Show ("Operation complete")
      >
      > End Sub
      >
      > to extract a entry to a stream
      >
      > Private Overloads Function Unzip(ByVal strSource As String, ByVal
      > strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean
      >
      > If File.Exists(str Source) Then
      >
      > Dim ZipStream As ZipInputStream
      >
      > Try
      >
      > ZipStream = New ZipInputStream( File.OpenRead(s trSource))
      >
      > ZipStream.Passw ord = "your own prefered password here"
      >
      > Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()
      >
      > Dim size As Integer
      >
      > Do Until TheEntry Is Nothing
      >
      > If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then
      >
      > Dim data(1024) As Byte
      >
      > newms = New MemoryStream
      >
      > Dim bw As New BinaryWriter(ne wms)
      >
      > Dim buffer(1024) As Byte
      >
      > Dim length As Integer
      >
      > Dim dataToRead As Long = TheEntry.Size
      >
      > While dataToRead > 0
      >
      > length = ZipStream.Read( buffer, 0, 1024)
      >
      > bw.Write(buffer , 0, length)
      >
      > ReDim buffer(1024) ' Clear the buffer
      >
      > dataToRead = dataToRead - length
      >
      > End While
      >
      > Return True
      >
      > End If
      >
      > TheEntry = ZipStream.GetNe xtEntry()
      >
      > Loop
      >
      > Catch e As Exception
      >
      > Finally
      >
      > ZipStream.Close ()
      >
      > End Try
      >
      > End If
      >
      > End Function
      >
      >
      > example to put the stream in a picturebox as a picture
      >
      > Dim newms As MemoryStream
      >
      > MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))
      >
      > PictureBox1.Ima ge = Image.FromStrea m(newms)
      >
      > well i hope this helped
      >
      >
      > regards
      >
      > Michel Posseth
      >
      >
      >
      >
      > "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
      > news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...[color=green]
      >> Hi! I am designing an application wich comes with image file. These
      >> images are copyrighted and they have to be accessible only from within
      >> the application. At first, I tought I was going to store them in a
      >> database, but since there will be much more than 2go, I'm going to need
      >> multiple database, and it's no good for CPU performance...
      >>
      >> I read about encrypting picture instead of storing them in a DB. But I
      >> only found thing about string encryption... Has anyone of you ever had to
      >> encrypt/decrypt image file? Anyone could point me a good tuorials or
      >> website or anything???
      >>
      >> Thank you, your help is really appreciated!
      >>
      >> Jean Christophe Avard!
      >>[/color]
      >
      >[/color]


      Comment

      • m.posseth

        #4
        Re: Encrypt/Decrypt Image Files

        the code i provided is all VB.Net however the library i talk about is
        written in C# ( it comes as source, and compiled dll )
        you may download it here
        ICSharpCode has 20 repositories available. Follow their code on GitHub.


        it has examples in C# and VB.Net however the method i showed below to
        create protected library`s is not in the examples i figured this out myself
        by exploring the library

        steps to take :

        You download the sharpziblib library, set a reference to the dll in your
        project , and you can start exploring


        if you need any further help feel free to ask , i can write a small demo for
        you ( if you have a newsreader that is capable of retrieving binary
        atachments ,, like Outlook express for instance )

        regards

        Michel Posseth






        "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
        news:eiXF1%23vu FHA.3756@tk2msf tngp13.phx.gbl. ..[color=blue]
        > thank you dude!, is this all C# code? and where do I write this? in a text
        > file that I call file.DLL ???
        > "m.posseth" <michelp@nohaus ystems.nl> wrote in message
        > news:uViXxFvuFH A.2504@tk2msftn gp13.phx.gbl...[color=green]
        >>
        >> yep me ,,,,,
        >>
        >> even better i have a +- 3 gb of pictures and had to ship them on a DVD to
        >> our customers in a somehow protected way
        >> then i found the following solution
        >>
        >> i was also searching for a way to group the picture files together in a
        >> sort kind of library
        >>
        >> then i found the solution in a nice opensource project
        >> ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
        >> compiled binary , source in C# with sharpdevelop project file , and
        >> examples ) and explored the classes
        >>
        >> i found that it is possible to create password protected library`s with
        >> this dll , it works flawless for me i compress multiple files to one
        >> password protected lib when i need to display the file i open the lib i
        >> search the entry in the lib load it to a memstream and send it directly
        >> to a picture box
        >>
        >>
        >> to create a protected lib
        >>
        >> Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
        >> System.EventArg s) Handles Button2.Click
        >> Dim strDirnames() As String = Directory.GetDi rectories(txtSo urceDir.Text)
        >>
        >> For Each strDirname As String In strDirnames
        >>
        >> Dim astrFileNames() As String = Directory.GetFi les(strDirname)
        >>
        >> Dim objCrc32 As New Crc32
        >>
        >> Dim strmZipOutputSt ream As ZipOutputStream
        >>
        >> strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\" &
        >> Path.GetFileNam e(strDirname) & ".cp"))
        >>
        >> strmZipOutputSt ream.Password = "your own prefered password here"
        >>
        >> strmZipOutputSt ream.SetLevel(6 )
        >>
        >> REM Compression Level: 0-9
        >>
        >> REM 0: no(Compression)
        >>
        >> REM 9: maximum compression
        >>
        >> Dim strFile As String
        >>
        >> For Each strFile In astrFileNames
        >>
        >> Dim strmFile As FileStream = File.OpenRead(s trFile)
        >>
        >> Dim abyBuffer(strmF ile.Length - 1) As Byte
        >>
        >> strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
        >>
        >> Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
        >>
        >> objZipEntry.Dat eTime = DateTime.Now
        >>
        >> objZipEntry.Siz e = strmFile.Length
        >>
        >> strmFile.Close( )
        >>
        >> objCrc32.Reset( )
        >>
        >> objCrc32.Update (abyBuffer)
        >>
        >> objZipEntry.Crc = objCrc32.Value
        >>
        >> strmZipOutputSt ream.PutNextEnt ry(objZipEntry)
        >>
        >> strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)
        >>
        >> Next
        >>
        >> strmZipOutputSt ream.Finish()
        >>
        >> strmZipOutputSt ream.Close()
        >>
        >>
        >>
        >> Next
        >>
        >>
        >>
        >>
        >> MessageBox.Show ("Operation complete")
        >>
        >> End Sub
        >>
        >> to extract a entry to a stream
        >>
        >> Private Overloads Function Unzip(ByVal strSource As String, ByVal
        >> strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean
        >>
        >> If File.Exists(str Source) Then
        >>
        >> Dim ZipStream As ZipInputStream
        >>
        >> Try
        >>
        >> ZipStream = New ZipInputStream( File.OpenRead(s trSource))
        >>
        >> ZipStream.Passw ord = "your own prefered password here"
        >>
        >> Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()
        >>
        >> Dim size As Integer
        >>
        >> Do Until TheEntry Is Nothing
        >>
        >> If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then
        >>
        >> Dim data(1024) As Byte
        >>
        >> newms = New MemoryStream
        >>
        >> Dim bw As New BinaryWriter(ne wms)
        >>
        >> Dim buffer(1024) As Byte
        >>
        >> Dim length As Integer
        >>
        >> Dim dataToRead As Long = TheEntry.Size
        >>
        >> While dataToRead > 0
        >>
        >> length = ZipStream.Read( buffer, 0, 1024)
        >>
        >> bw.Write(buffer , 0, length)
        >>
        >> ReDim buffer(1024) ' Clear the buffer
        >>
        >> dataToRead = dataToRead - length
        >>
        >> End While
        >>
        >> Return True
        >>
        >> End If
        >>
        >> TheEntry = ZipStream.GetNe xtEntry()
        >>
        >> Loop
        >>
        >> Catch e As Exception
        >>
        >> Finally
        >>
        >> ZipStream.Close ()
        >>
        >> End Try
        >>
        >> End If
        >>
        >> End Function
        >>
        >>
        >> example to put the stream in a picturebox as a picture
        >>
        >> Dim newms As MemoryStream
        >>
        >> MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))
        >>
        >> PictureBox1.Ima ge = Image.FromStrea m(newms)
        >>
        >> well i hope this helped
        >>
        >>
        >> regards
        >>
        >> Michel Posseth
        >>
        >>
        >>
        >>
        >> "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
        >> news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...[color=darkred]
        >>> Hi! I am designing an application wich comes with image file. These
        >>> images are copyrighted and they have to be accessible only from within
        >>> the application. At first, I tought I was going to store them in a
        >>> database, but since there will be much more than 2go, I'm going to need
        >>> multiple database, and it's no good for CPU performance...
        >>>
        >>> I read about encrypting picture instead of storing them in a DB. But I
        >>> only found thing about string encryption... Has anyone of you ever had
        >>> to encrypt/decrypt image file? Anyone could point me a good tuorials or
        >>> website or anything???
        >>>
        >>> Thank you, your help is really appreciated!
        >>>
        >>> Jean Christophe Avard!
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Jean Christophe Avard

          #5
          Re: Encrypt/Decrypt Image Files

          Thank you Michel, your help is really appreciated! I didn't know the REM
          command, I thought that was C# or something complicated... though it's just
          commenting haha, anyway. So with the code you provided, I can do all what I
          need, encrypt and decrypt, I don't need anything else, well I'll give this a
          try and let you know! Thanks again for this great help dude!! that is really
          appreciated, I'm thankful!

          jc


          "m.posseth" <michelp@nohaus ystems.nl> wrote in message
          news:e993vT2uFH A.3252@TK2MSFTN GP10.phx.gbl...[color=blue]
          > the code i provided is all VB.Net however the library i talk about is
          > written in C# ( it comes as source, and compiled dll )
          > you may download it here
          > http://www.icsharpcode.net/OpenSourc...b/Default.aspx
          >
          > it has examples in C# and VB.Net however the method i showed below to
          > create protected library`s is not in the examples i figured this out
          > myself by exploring the library
          >
          > steps to take :
          >
          > You download the sharpziblib library, set a reference to the dll in your
          > project , and you can start exploring
          >
          >
          > if you need any further help feel free to ask , i can write a small demo
          > for you ( if you have a newsreader that is capable of retrieving binary
          > atachments ,, like Outlook express for instance )
          >
          > regards
          >
          > Michel Posseth
          >
          >
          >
          >
          >
          >
          > "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
          > news:eiXF1%23vu FHA.3756@tk2msf tngp13.phx.gbl. ..[color=green]
          >> thank you dude!, is this all C# code? and where do I write this? in a
          >> text file that I call file.DLL ???
          >> "m.posseth" <michelp@nohaus ystems.nl> wrote in message
          >> news:uViXxFvuFH A.2504@tk2msftn gp13.phx.gbl...[color=darkred]
          >>>
          >>> yep me ,,,,,
          >>>
          >>> even better i have a +- 3 gb of pictures and had to ship them on a DVD
          >>> to our customers in a somehow protected way
          >>> then i found the following solution
          >>>
          >>> i was also searching for a way to group the picture files together in
          >>> a sort kind of library
          >>>
          >>> then i found the solution in a nice opensource project
          >>> ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
          >>> compiled binary , source in C# with sharpdevelop project file , and
          >>> examples ) and explored the classes
          >>>
          >>> i found that it is possible to create password protected library`s
          >>> with this dll , it works flawless for me i compress multiple files to
          >>> one password protected lib when i need to display the file i open the
          >>> lib i search the entry in the lib load it to a memstream and send it
          >>> directly to a picture box
          >>>
          >>>
          >>> to create a protected lib
          >>>
          >>> Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
          >>> System.EventArg s) Handles Button2.Click
          >>> Dim strDirnames() As String =
          >>> Directory.GetDi rectories(txtSo urceDir.Text)
          >>>
          >>> For Each strDirname As String In strDirnames
          >>>
          >>> Dim astrFileNames() As String = Directory.GetFi les(strDirname)
          >>>
          >>> Dim objCrc32 As New Crc32
          >>>
          >>> Dim strmZipOutputSt ream As ZipOutputStream
          >>>
          >>> strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\" &
          >>> Path.GetFileNam e(strDirname) & ".cp"))
          >>>
          >>> strmZipOutputSt ream.Password = "your own prefered password here"
          >>>
          >>> strmZipOutputSt ream.SetLevel(6 )
          >>>
          >>> REM Compression Level: 0-9
          >>>
          >>> REM 0: no(Compression)
          >>>
          >>> REM 9: maximum compression
          >>>
          >>> Dim strFile As String
          >>>
          >>> For Each strFile In astrFileNames
          >>>
          >>> Dim strmFile As FileStream = File.OpenRead(s trFile)
          >>>
          >>> Dim abyBuffer(strmF ile.Length - 1) As Byte
          >>>
          >>> strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
          >>>
          >>> Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
          >>>
          >>> objZipEntry.Dat eTime = DateTime.Now
          >>>
          >>> objZipEntry.Siz e = strmFile.Length
          >>>
          >>> strmFile.Close( )
          >>>
          >>> objCrc32.Reset( )
          >>>
          >>> objCrc32.Update (abyBuffer)
          >>>
          >>> objZipEntry.Crc = objCrc32.Value
          >>>
          >>> strmZipOutputSt ream.PutNextEnt ry(objZipEntry)
          >>>
          >>> strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)
          >>>
          >>> Next
          >>>
          >>> strmZipOutputSt ream.Finish()
          >>>
          >>> strmZipOutputSt ream.Close()
          >>>
          >>>
          >>>
          >>> Next
          >>>
          >>>
          >>>
          >>>
          >>> MessageBox.Show ("Operation complete")
          >>>
          >>> End Sub
          >>>
          >>> to extract a entry to a stream
          >>>
          >>> Private Overloads Function Unzip(ByVal strSource As String, ByVal
          >>> strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean
          >>>
          >>> If File.Exists(str Source) Then
          >>>
          >>> Dim ZipStream As ZipInputStream
          >>>
          >>> Try
          >>>
          >>> ZipStream = New ZipInputStream( File.OpenRead(s trSource))
          >>>
          >>> ZipStream.Passw ord = "your own prefered password here"
          >>>
          >>> Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()
          >>>
          >>> Dim size As Integer
          >>>
          >>> Do Until TheEntry Is Nothing
          >>>
          >>> If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then
          >>>
          >>> Dim data(1024) As Byte
          >>>
          >>> newms = New MemoryStream
          >>>
          >>> Dim bw As New BinaryWriter(ne wms)
          >>>
          >>> Dim buffer(1024) As Byte
          >>>
          >>> Dim length As Integer
          >>>
          >>> Dim dataToRead As Long = TheEntry.Size
          >>>
          >>> While dataToRead > 0
          >>>
          >>> length = ZipStream.Read( buffer, 0, 1024)
          >>>
          >>> bw.Write(buffer , 0, length)
          >>>
          >>> ReDim buffer(1024) ' Clear the buffer
          >>>
          >>> dataToRead = dataToRead - length
          >>>
          >>> End While
          >>>
          >>> Return True
          >>>
          >>> End If
          >>>
          >>> TheEntry = ZipStream.GetNe xtEntry()
          >>>
          >>> Loop
          >>>
          >>> Catch e As Exception
          >>>
          >>> Finally
          >>>
          >>> ZipStream.Close ()
          >>>
          >>> End Try
          >>>
          >>> End If
          >>>
          >>> End Function
          >>>
          >>>
          >>> example to put the stream in a picturebox as a picture
          >>>
          >>> Dim newms As MemoryStream
          >>>
          >>> MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))
          >>>
          >>> PictureBox1.Ima ge = Image.FromStrea m(newms)
          >>>
          >>> well i hope this helped
          >>>
          >>>
          >>> regards
          >>>
          >>> Michel Posseth
          >>>
          >>>
          >>>
          >>>
          >>> "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
          >>> news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...
          >>>> Hi! I am designing an application wich comes with image file. These
          >>>> images are copyrighted and they have to be accessible only from within
          >>>> the application. At first, I tought I was going to store them in a
          >>>> database, but since there will be much more than 2go, I'm going to need
          >>>> multiple database, and it's no good for CPU performance...
          >>>>
          >>>> I read about encrypting picture instead of storing them in a DB. But I
          >>>> only found thing about string encryption... Has anyone of you ever had
          >>>> to encrypt/decrypt image file? Anyone could point me a good tuorials or
          >>>> website or anything???
          >>>>
          >>>> Thank you, your help is really appreciated!
          >>>>
          >>>> Jean Christophe Avard!
          >>>>
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Jean Christophe Avard

            #6
            Re: Encrypt/Decrypt Image Files

            Sorry I posted too quicly, could you just tell me what namespace are
            needed?? and what the command line to extract files?

            thanks again!
            jc


            "m.posseth" <michelp@nohaus ystems.nl> wrote in message
            news:e993vT2uFH A.3252@TK2MSFTN GP10.phx.gbl...[color=blue]
            > the code i provided is all VB.Net however the library i talk about is
            > written in C# ( it comes as source, and compiled dll )
            > you may download it here
            > http://www.icsharpcode.net/OpenSourc...b/Default.aspx
            >
            > it has examples in C# and VB.Net however the method i showed below to
            > create protected library`s is not in the examples i figured this out
            > myself by exploring the library
            >
            > steps to take :
            >
            > You download the sharpziblib library, set a reference to the dll in your
            > project , and you can start exploring
            >
            >
            > if you need any further help feel free to ask , i can write a small demo
            > for you ( if you have a newsreader that is capable of retrieving binary
            > atachments ,, like Outlook express for instance )
            >
            > regards
            >
            > Michel Posseth
            >
            >
            >
            >
            >
            >
            > "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
            > news:eiXF1%23vu FHA.3756@tk2msf tngp13.phx.gbl. ..[color=green]
            >> thank you dude!, is this all C# code? and where do I write this? in a
            >> text file that I call file.DLL ???
            >> "m.posseth" <michelp@nohaus ystems.nl> wrote in message
            >> news:uViXxFvuFH A.2504@tk2msftn gp13.phx.gbl...[color=darkred]
            >>>
            >>> yep me ,,,,,
            >>>
            >>> even better i have a +- 3 gb of pictures and had to ship them on a DVD
            >>> to our customers in a somehow protected way
            >>> then i found the following solution
            >>>
            >>> i was also searching for a way to group the picture files together in
            >>> a sort kind of library
            >>>
            >>> then i found the solution in a nice opensource project
            >>> ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
            >>> compiled binary , source in C# with sharpdevelop project file , and
            >>> examples ) and explored the classes
            >>>
            >>> i found that it is possible to create password protected library`s
            >>> with this dll , it works flawless for me i compress multiple files to
            >>> one password protected lib when i need to display the file i open the
            >>> lib i search the entry in the lib load it to a memstream and send it
            >>> directly to a picture box
            >>>
            >>>
            >>> to create a protected lib
            >>>
            >>> Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
            >>> System.EventArg s) Handles Button2.Click
            >>> Dim strDirnames() As String =
            >>> Directory.GetDi rectories(txtSo urceDir.Text)
            >>>
            >>> For Each strDirname As String In strDirnames
            >>>
            >>> Dim astrFileNames() As String = Directory.GetFi les(strDirname)
            >>>
            >>> Dim objCrc32 As New Crc32
            >>>
            >>> Dim strmZipOutputSt ream As ZipOutputStream
            >>>
            >>> strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\" &
            >>> Path.GetFileNam e(strDirname) & ".cp"))
            >>>
            >>> strmZipOutputSt ream.Password = "your own prefered password here"
            >>>
            >>> strmZipOutputSt ream.SetLevel(6 )
            >>>
            >>> REM Compression Level: 0-9
            >>>
            >>> REM 0: no(Compression)
            >>>
            >>> REM 9: maximum compression
            >>>
            >>> Dim strFile As String
            >>>
            >>> For Each strFile In astrFileNames
            >>>
            >>> Dim strmFile As FileStream = File.OpenRead(s trFile)
            >>>
            >>> Dim abyBuffer(strmF ile.Length - 1) As Byte
            >>>
            >>> strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
            >>>
            >>> Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
            >>>
            >>> objZipEntry.Dat eTime = DateTime.Now
            >>>
            >>> objZipEntry.Siz e = strmFile.Length
            >>>
            >>> strmFile.Close( )
            >>>
            >>> objCrc32.Reset( )
            >>>
            >>> objCrc32.Update (abyBuffer)
            >>>
            >>> objZipEntry.Crc = objCrc32.Value
            >>>
            >>> strmZipOutputSt ream.PutNextEnt ry(objZipEntry)
            >>>
            >>> strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)
            >>>
            >>> Next
            >>>
            >>> strmZipOutputSt ream.Finish()
            >>>
            >>> strmZipOutputSt ream.Close()
            >>>
            >>>
            >>>
            >>> Next
            >>>
            >>>
            >>>
            >>>
            >>> MessageBox.Show ("Operation complete")
            >>>
            >>> End Sub
            >>>
            >>> to extract a entry to a stream
            >>>
            >>> Private Overloads Function Unzip(ByVal strSource As String, ByVal
            >>> strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean
            >>>
            >>> If File.Exists(str Source) Then
            >>>
            >>> Dim ZipStream As ZipInputStream
            >>>
            >>> Try
            >>>
            >>> ZipStream = New ZipInputStream( File.OpenRead(s trSource))
            >>>
            >>> ZipStream.Passw ord = "your own prefered password here"
            >>>
            >>> Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()
            >>>
            >>> Dim size As Integer
            >>>
            >>> Do Until TheEntry Is Nothing
            >>>
            >>> If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then
            >>>
            >>> Dim data(1024) As Byte
            >>>
            >>> newms = New MemoryStream
            >>>
            >>> Dim bw As New BinaryWriter(ne wms)
            >>>
            >>> Dim buffer(1024) As Byte
            >>>
            >>> Dim length As Integer
            >>>
            >>> Dim dataToRead As Long = TheEntry.Size
            >>>
            >>> While dataToRead > 0
            >>>
            >>> length = ZipStream.Read( buffer, 0, 1024)
            >>>
            >>> bw.Write(buffer , 0, length)
            >>>
            >>> ReDim buffer(1024) ' Clear the buffer
            >>>
            >>> dataToRead = dataToRead - length
            >>>
            >>> End While
            >>>
            >>> Return True
            >>>
            >>> End If
            >>>
            >>> TheEntry = ZipStream.GetNe xtEntry()
            >>>
            >>> Loop
            >>>
            >>> Catch e As Exception
            >>>
            >>> Finally
            >>>
            >>> ZipStream.Close ()
            >>>
            >>> End Try
            >>>
            >>> End If
            >>>
            >>> End Function
            >>>
            >>>
            >>> example to put the stream in a picturebox as a picture
            >>>
            >>> Dim newms As MemoryStream
            >>>
            >>> MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))
            >>>
            >>> PictureBox1.Ima ge = Image.FromStrea m(newms)
            >>>
            >>> well i hope this helped
            >>>
            >>>
            >>> regards
            >>>
            >>> Michel Posseth
            >>>
            >>>
            >>>
            >>>
            >>> "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
            >>> news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...
            >>>> Hi! I am designing an application wich comes with image file. These
            >>>> images are copyrighted and they have to be accessible only from within
            >>>> the application. At first, I tought I was going to store them in a
            >>>> database, but since there will be much more than 2go, I'm going to need
            >>>> multiple database, and it's no good for CPU performance...
            >>>>
            >>>> I read about encrypting picture instead of storing them in a DB. But I
            >>>> only found thing about string encryption... Has anyone of you ever had
            >>>> to encrypt/decrypt image file? Anyone could point me a good tuorials or
            >>>> website or anything???
            >>>>
            >>>> Thank you, your help is really appreciated!
            >>>>
            >>>> Jean Christophe Avard!
            >>>>
            >>>
            >>>[/color]
            >>
            >>[/color]
            >
            >[/color]


            Comment

            • Jean Christophe Avard

              #7
              Re: Encrypt/Decrypt Image Files

              ok, have the code you gave me, I downloaded the ICSharpCode dll, I
              referenced it inside my project. But now, when I type in "c:\12\" wich
              contains "New Folder" wich contains 3 JPG, I get an error, saying "Size was
              66, but I expected 5280262" I joined a screenshot of the error. Have you
              ever come to this?

              "m.posseth" <michelp@nohaus ystems.nl> wrote in message
              news:e993vT2uFH A.3252@TK2MSFTN GP10.phx.gbl...[color=blue]
              > the code i provided is all VB.Net however the library i talk about is
              > written in C# ( it comes as source, and compiled dll )
              > you may download it here
              > http://www.icsharpcode.net/OpenSourc...b/Default.aspx
              >
              > it has examples in C# and VB.Net however the method i showed below to
              > create protected library`s is not in the examples i figured this out
              > myself
              > by exploring the library
              >
              > steps to take :
              >
              > You download the sharpziblib library, set a reference to the dll in your
              > project , and you can start exploring
              >
              >
              > if you need any further help feel free to ask , i can write a small demo
              > for
              > you ( if you have a newsreader that is capable of retrieving binary
              > atachments ,, like Outlook express for instance )
              >
              > regards
              >
              > Michel Posseth
              >
              >
              >
              >
              >
              >
              > "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
              > news:eiXF1%23vu FHA.3756@tk2msf tngp13.phx.gbl. ..[color=green]
              >> thank you dude!, is this all C# code? and where do I write this? in a
              >> text
              >> file that I call file.DLL ???
              >> "m.posseth" <michelp@nohaus ystems.nl> wrote in message
              >> news:uViXxFvuFH A.2504@tk2msftn gp13.phx.gbl...[color=darkred]
              >>>
              >>> yep me ,,,,,
              >>>
              >>> even better i have a +- 3 gb of pictures and had to ship them on a DVD
              >>> to
              >>> our customers in a somehow protected way
              >>> then i found the following solution
              >>>
              >>> i was also searching for a way to group the picture files together in
              >>> a
              >>> sort kind of library
              >>>
              >>> then i found the solution in a nice opensource project
              >>> ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
              >>> compiled binary , source in C# with sharpdevelop project file , and
              >>> examples ) and explored the classes
              >>>
              >>> i found that it is possible to create password protected library`s
              >>> with
              >>> this dll , it works flawless for me i compress multiple files to one
              >>> password protected lib when i need to display the file i open the lib i
              >>> search the entry in the lib load it to a memstream and send it
              >>> directly
              >>> to a picture box
              >>>
              >>>
              >>> to create a protected lib
              >>>
              >>> Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
              >>> System.EventArg s) Handles Button2.Click
              >>> Dim strDirnames() As String =
              >>> Directory.GetDi rectories(txtSo urceDir.Text)
              >>>
              >>> For Each strDirname As String In strDirnames
              >>>
              >>> Dim astrFileNames() As String = Directory.GetFi les(strDirname)
              >>>
              >>> Dim objCrc32 As New Crc32
              >>>
              >>> Dim strmZipOutputSt ream As ZipOutputStream
              >>>
              >>> strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\" &
              >>> Path.GetFileNam e(strDirname) & ".cp"))
              >>>
              >>> strmZipOutputSt ream.Password = "your own prefered password here"
              >>>
              >>> strmZipOutputSt ream.SetLevel(6 )
              >>>
              >>> REM Compression Level: 0-9
              >>>
              >>> REM 0: no(Compression)
              >>>
              >>> REM 9: maximum compression
              >>>
              >>> Dim strFile As String
              >>>
              >>> For Each strFile In astrFileNames
              >>>
              >>> Dim strmFile As FileStream = File.OpenRead(s trFile)
              >>>
              >>> Dim abyBuffer(strmF ile.Length - 1) As Byte
              >>>
              >>> strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
              >>>
              >>> Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
              >>>
              >>> objZipEntry.Dat eTime = DateTime.Now
              >>>
              >>> objZipEntry.Siz e = strmFile.Length
              >>>
              >>> strmFile.Close( )
              >>>
              >>> objCrc32.Reset( )
              >>>
              >>> objCrc32.Update (abyBuffer)
              >>>
              >>> objZipEntry.Crc = objCrc32.Value
              >>>
              >>> strmZipOutputSt ream.PutNextEnt ry(objZipEntry)
              >>>
              >>> strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)
              >>>
              >>> Next
              >>>
              >>> strmZipOutputSt ream.Finish()
              >>>
              >>> strmZipOutputSt ream.Close()
              >>>
              >>>
              >>>
              >>> Next
              >>>
              >>>
              >>>
              >>>
              >>> MessageBox.Show ("Operation complete")
              >>>
              >>> End Sub
              >>>
              >>> to extract a entry to a stream
              >>>
              >>> Private Overloads Function Unzip(ByVal strSource As String, ByVal
              >>> strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean
              >>>
              >>> If File.Exists(str Source) Then
              >>>
              >>> Dim ZipStream As ZipInputStream
              >>>
              >>> Try
              >>>
              >>> ZipStream = New ZipInputStream( File.OpenRead(s trSource))
              >>>
              >>> ZipStream.Passw ord = "your own prefered password here"
              >>>
              >>> Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()
              >>>
              >>> Dim size As Integer
              >>>
              >>> Do Until TheEntry Is Nothing
              >>>
              >>> If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then
              >>>
              >>> Dim data(1024) As Byte
              >>>
              >>> newms = New MemoryStream
              >>>
              >>> Dim bw As New BinaryWriter(ne wms)
              >>>
              >>> Dim buffer(1024) As Byte
              >>>
              >>> Dim length As Integer
              >>>
              >>> Dim dataToRead As Long = TheEntry.Size
              >>>
              >>> While dataToRead > 0
              >>>
              >>> length = ZipStream.Read( buffer, 0, 1024)
              >>>
              >>> bw.Write(buffer , 0, length)
              >>>
              >>> ReDim buffer(1024) ' Clear the buffer
              >>>
              >>> dataToRead = dataToRead - length
              >>>
              >>> End While
              >>>
              >>> Return True
              >>>
              >>> End If
              >>>
              >>> TheEntry = ZipStream.GetNe xtEntry()
              >>>
              >>> Loop
              >>>
              >>> Catch e As Exception
              >>>
              >>> Finally
              >>>
              >>> ZipStream.Close ()
              >>>
              >>> End Try
              >>>
              >>> End If
              >>>
              >>> End Function
              >>>
              >>>
              >>> example to put the stream in a picturebox as a picture
              >>>
              >>> Dim newms As MemoryStream
              >>>
              >>> MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))
              >>>
              >>> PictureBox1.Ima ge = Image.FromStrea m(newms)
              >>>
              >>> well i hope this helped
              >>>
              >>>
              >>> regards
              >>>
              >>> Michel Posseth
              >>>
              >>>
              >>>
              >>>
              >>> "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
              >>> news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...
              >>>> Hi! I am designing an application wich comes with image file. These
              >>>> images are copyrighted and they have to be accessible only from within
              >>>> the application. At first, I tought I was going to store them in a
              >>>> database, but since there will be much more than 2go, I'm going to need
              >>>> multiple database, and it's no good for CPU performance...
              >>>>
              >>>> I read about encrypting picture instead of storing them in a DB. But I
              >>>> only found thing about string encryption... Has anyone of you ever had
              >>>> to encrypt/decrypt image file? Anyone could point me a good tuorials or
              >>>> website or anything???
              >>>>
              >>>> Thank you, your help is really appreciated!
              >>>>
              >>>> Jean Christophe Avard!
              >>>>
              >>>
              >>>[/color]
              >>
              >>[/color]
              >
              >[/color]




              Comment

              • m.posseth

                #8
                Re: Encrypt/Decrypt Image Files


                strange ,,, no i never encountered this problem ....


                i have sent you by e-mail ( to the adress you sent with to me ) a working
                example

                it shows how to create the libs , it shows how to extract a file out of the
                lib , and it shows how to bind the stream to a picturebox control


                regards

                Michel Posseth



                "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
                news:%23w5jUGSv FHA.1028@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                > ok, have the code you gave me, I downloaded the ICSharpCode dll, I
                > referenced it inside my project. But now, when I type in "c:\12\" wich
                > contains "New Folder" wich contains 3 JPG, I get an error, saying "Size
                > was 66, but I expected 5280262" I joined a screenshot of the error. Have
                > you ever come to this?
                >
                > "m.posseth" <michelp@nohaus ystems.nl> wrote in message
                > news:e993vT2uFH A.3252@TK2MSFTN GP10.phx.gbl...[color=green]
                >> the code i provided is all VB.Net however the library i talk about is
                >> written in C# ( it comes as source, and compiled dll )
                >> you may download it here
                >> http://www.icsharpcode.net/OpenSourc...b/Default.aspx
                >>
                >> it has examples in C# and VB.Net however the method i showed below to
                >> create protected library`s is not in the examples i figured this out
                >> myself
                >> by exploring the library
                >>
                >> steps to take :
                >>
                >> You download the sharpziblib library, set a reference to the dll in your
                >> project , and you can start exploring
                >>
                >>
                >> if you need any further help feel free to ask , i can write a small demo
                >> for
                >> you ( if you have a newsreader that is capable of retrieving binary
                >> atachments ,, like Outlook express for instance )
                >>
                >> regards
                >>
                >> Michel Posseth
                >>
                >>
                >>
                >>
                >>
                >>
                >> "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
                >> news:eiXF1%23vu FHA.3756@tk2msf tngp13.phx.gbl. ..[color=darkred]
                >>> thank you dude!, is this all C# code? and where do I write this? in a
                >>> text
                >>> file that I call file.DLL ???
                >>> "m.posseth" <michelp@nohaus ystems.nl> wrote in message
                >>> news:uViXxFvuFH A.2504@tk2msftn gp13.phx.gbl...
                >>>>
                >>>> yep me ,,,,,
                >>>>
                >>>> even better i have a +- 3 gb of pictures and had to ship them on a DVD
                >>>> to
                >>>> our customers in a somehow protected way
                >>>> then i found the following solution
                >>>>
                >>>> i was also searching for a way to group the picture files together in
                >>>> a
                >>>> sort kind of library
                >>>>
                >>>> then i found the solution in a nice opensource project
                >>>> ICSharpCode.Sha rpZipLib.dll i downloaded the hole package ( comes as
                >>>> compiled binary , source in C# with sharpdevelop project file , and
                >>>> examples ) and explored the classes
                >>>>
                >>>> i found that it is possible to create password protected library`s
                >>>> with
                >>>> this dll , it works flawless for me i compress multiple files to one
                >>>> password protected lib when i need to display the file i open the lib i
                >>>> search the entry in the lib load it to a memstream and send it
                >>>> directly
                >>>> to a picture box
                >>>>
                >>>>
                >>>> to create a protected lib
                >>>>
                >>>> Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
                >>>> System.EventArg s) Handles Button2.Click
                >>>> Dim strDirnames() As String =
                >>>> Directory.GetDi rectories(txtSo urceDir.Text)
                >>>>
                >>>> For Each strDirname As String In strDirnames
                >>>>
                >>>> Dim astrFileNames() As String = Directory.GetFi les(strDirname)
                >>>>
                >>>> Dim objCrc32 As New Crc32
                >>>>
                >>>> Dim strmZipOutputSt ream As ZipOutputStream
                >>>>
                >>>> strmZipOutputSt ream = New ZipOutputStream (File.Create("D :\compressed\"
                >>>> &
                >>>> Path.GetFileNam e(strDirname) & ".cp"))
                >>>>
                >>>> strmZipOutputSt ream.Password = "your own prefered password here"
                >>>>
                >>>> strmZipOutputSt ream.SetLevel(6 )
                >>>>
                >>>> REM Compression Level: 0-9
                >>>>
                >>>> REM 0: no(Compression)
                >>>>
                >>>> REM 9: maximum compression
                >>>>
                >>>> Dim strFile As String
                >>>>
                >>>> For Each strFile In astrFileNames
                >>>>
                >>>> Dim strmFile As FileStream = File.OpenRead(s trFile)
                >>>>
                >>>> Dim abyBuffer(strmF ile.Length - 1) As Byte
                >>>>
                >>>> strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
                >>>>
                >>>> Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
                >>>>
                >>>> objZipEntry.Dat eTime = DateTime.Now
                >>>>
                >>>> objZipEntry.Siz e = strmFile.Length
                >>>>
                >>>> strmFile.Close( )
                >>>>
                >>>> objCrc32.Reset( )
                >>>>
                >>>> objCrc32.Update (abyBuffer)
                >>>>
                >>>> objZipEntry.Crc = objCrc32.Value
                >>>>
                >>>> strmZipOutputSt ream.PutNextEnt ry(objZipEntry)
                >>>>
                >>>> strmZipOutputSt ream.Write(abyB uffer, 0, abyBuffer.Lengt h)
                >>>>
                >>>> Next
                >>>>
                >>>> strmZipOutputSt ream.Finish()
                >>>>
                >>>> strmZipOutputSt ream.Close()
                >>>>
                >>>>
                >>>>
                >>>> Next
                >>>>
                >>>>
                >>>>
                >>>>
                >>>> MessageBox.Show ("Operation complete")
                >>>>
                >>>> End Sub
                >>>>
                >>>> to extract a entry to a stream
                >>>>
                >>>> Private Overloads Function Unzip(ByVal strSource As String, ByVal
                >>>> strFileToExtrac t As String, ByRef newms As MemoryStream) As Boolean
                >>>>
                >>>> If File.Exists(str Source) Then
                >>>>
                >>>> Dim ZipStream As ZipInputStream
                >>>>
                >>>> Try
                >>>>
                >>>> ZipStream = New ZipInputStream( File.OpenRead(s trSource))
                >>>>
                >>>> ZipStream.Passw ord = "your own prefered password here"
                >>>>
                >>>> Dim TheEntry As ZipEntry = ZipStream.GetNe xtEntry()
                >>>>
                >>>> Dim size As Integer
                >>>>
                >>>> Do Until TheEntry Is Nothing
                >>>>
                >>>> If Path.GetFileNam e(TheEntry.Name ) = strFileToExtrac t Then
                >>>>
                >>>> Dim data(1024) As Byte
                >>>>
                >>>> newms = New MemoryStream
                >>>>
                >>>> Dim bw As New BinaryWriter(ne wms)
                >>>>
                >>>> Dim buffer(1024) As Byte
                >>>>
                >>>> Dim length As Integer
                >>>>
                >>>> Dim dataToRead As Long = TheEntry.Size
                >>>>
                >>>> While dataToRead > 0
                >>>>
                >>>> length = ZipStream.Read( buffer, 0, 1024)
                >>>>
                >>>> bw.Write(buffer , 0, length)
                >>>>
                >>>> ReDim buffer(1024) ' Clear the buffer
                >>>>
                >>>> dataToRead = dataToRead - length
                >>>>
                >>>> End While
                >>>>
                >>>> Return True
                >>>>
                >>>> End If
                >>>>
                >>>> TheEntry = ZipStream.GetNe xtEntry()
                >>>>
                >>>> Loop
                >>>>
                >>>> Catch e As Exception
                >>>>
                >>>> Finally
                >>>>
                >>>> ZipStream.Close ()
                >>>>
                >>>> End Try
                >>>>
                >>>> End If
                >>>>
                >>>> End Function
                >>>>
                >>>>
                >>>> example to put the stream in a picturebox as a picture
                >>>>
                >>>> Dim newms As MemoryStream
                >>>>
                >>>> MsgBox(Unzip("D :\AD.cp", "3DA3.gif", newms))
                >>>>
                >>>> PictureBox1.Ima ge = Image.FromStrea m(newms)
                >>>>
                >>>> well i hope this helped
                >>>>
                >>>>
                >>>> regards
                >>>>
                >>>> Michel Posseth
                >>>>
                >>>>
                >>>>
                >>>>
                >>>> "Jean Christophe Avard" <NO.SP@M.BITC H> wrote in message
                >>>> news:eyll7zsuFH A.2064@TK2MSFTN GP09.phx.gbl...
                >>>>> Hi! I am designing an application wich comes with image file. These
                >>>>> images are copyrighted and they have to be accessible only from within
                >>>>> the application. At first, I tought I was going to store them in a
                >>>>> database, but since there will be much more than 2go, I'm going to
                >>>>> need
                >>>>> multiple database, and it's no good for CPU performance...
                >>>>>
                >>>>> I read about encrypting picture instead of storing them in a DB. But I
                >>>>> only found thing about string encryption... Has anyone of you ever had
                >>>>> to encrypt/decrypt image file? Anyone could point me a good tuorials
                >>>>> or
                >>>>> website or anything???
                >>>>>
                >>>>> Thank you, your help is really appreciated!
                >>>>>
                >>>>> Jean Christophe Avard!
                >>>>>
                >>>>
                >>>>
                >>>
                >>>[/color]
                >>
                >>[/color]
                >
                >
                >[/color]


                Comment

                Working...