Click here to Skip to main content
15,892,517 members

Comments by zomalaja (Top 12 by date)

zomalaja 27-Nov-17 20:26pm View    
Thanks for nothing - hopefully someone will see my request and remove this thread.
zomalaja 24-Nov-17 12:08pm View    
Attn any Moderator - if possible please delete this entire thread, it has been a total waste of my time and none of the information I was given is the least bit useful.

Thanks in advance.
zomalaja 16-Nov-17 19:08pm View    
Deleted
Here is a sample of the EXACT code used to create the bitmap.
Option Strict On
Imports System.IO
Imports System.IO.Compression
Imports System.Security.Cryptography
Imports System.Text

Public Class Form1
    Private WithEvents TxtStatus As New TextBox
    Private WithEvents BtnTest As New Button
    Private WithEvents TxtEncryptKey As New TextBox
    Private Label1 As New Label
    Private WithEvents BtnLoadFile As New Button
    Private TxtPlain As New RichTextBox
    Private RNG As New Random
    Private CompressedFileName As String
    Private CompressedLength As Long
    Private InputFileName As String
    Private InputLength As Long
    Private ColorList As New List(Of Color)
    Private MainBitmap As Bitmap
    Private EncryptKey As String
    Private ImageWidth As Integer
    Private ImageHeight As Integer

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        AutoScaleMode = AutoScaleMode.Font
        ClientSize = New Size(604, 270)
        MinimumSize = Size
        With TxtStatus
            .Anchor = CType(((AnchorStyles.Bottom Or AnchorStyles.Left) Or AnchorStyles.Right), AnchorStyles)
            .Location = New Point(4, 224)
            .Multiline = True
            .Size = New Size(594, 37)
        End With
        With BtnTest
            .Location = New Point(206, 188)
            .Size = New Size(120, 23)
            .Text = "Test"
        End With
        With TxtEncryptKey
            .Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) Or AnchorStyles.Right), AnchorStyles)
            .Location = New Point(80, 131)
            .Size = New Size(518, 22)
        End With
        With Label1
            .AutoSize = True
            .Location = New Point(3, 134)
            .Size = New Size(70, 14)
            .Text = "Password:"
        End With
        With BtnLoadFile
            .Location = New Point(80, 188)
            .Size = New Size(120, 23)
            .Text = "Load A File"
        End With
        With TxtPlain
            .Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) Or AnchorStyles.Right), AnchorStyles)
            .Location = New Point(4, 2)
            .Size = New Size(594, 123)
        End With

        With Me
            .Controls.Add(TxtPlain)
            .Controls.Add(BtnLoadFile)
            .Controls.Add(BtnTest)
            .Controls.Add(TxtStatus)
            .Controls.Add(Label1)
            .Controls.Add(TxtEncryptKey)
            .Font = New Font("Consolas", 9.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
            .Text = "ONLY FOR TESTING " & " " & Application.ProductVersion & " TESTING ONLY"
        End With

    End Sub

    Private Function GetSHA1Color(ByVal Input As String) As Color
        Dim SHA1Hasher As New SHA1Managed()
        Dim Hash As Byte() = SHA1Hasher.ComputeHash(Encoding.Default.GetBytes(Input))
        Return Color.FromArgb(255, Hash(0), Hash(1), Hash(2))
    End Function

    Private Function FillColorList(EncryptKey As String) As Boolean
        ColorList.Clear()
        Dim ColorToAdd As Color = Nothing
        For CharacterValue As Integer = 0 To 255
            ColorToAdd = GetSHA1Color(EncryptKey & Chr(CharacterValue))
            If ColorList.Contains(ColorToAdd) Then
                Return False
            Else
                ColorList.Add(ColorToAdd)
            End If
        Next
        Return True
    End Function

    Private Sub CompressFileToFile(InFile As String, Outfile As String)
        Dim InFileInfo As FileInfo = New FileInfo(InFile)
        Dim InFileLength As Long = InFileInfo.Length
        Dim Bytesread As Long = 0
        Dim BytesRemaining As Long = InFileLength
        Dim BufferSize As Long = InFileLength \ 100
        Dim BytesToRead As Long = BufferSize
        Dim buffer(CInt(BufferSize - 1)) As Byte
        Dim OutFileinfo As New FileInfo
zomalaja 12-Nov-17 13:38pm View    
Deleted
Untrusted code ? I was planning on posting Source Code, you know, plain text. How can that be trusted or untrusted ? You just read it and make sure there's nothing suspicious there.
zomalaja 11-Nov-17 15:33pm View    
Deleted
Either I am very confused or you are not reading what I am saying. Regarding the first two things you posted, I already commented as follows:

"If the program fails on the first attempt at processing a 50 MB file, what is supposed to have been disposed? The bitmap is disposed upon saving or starting a new encryption run. What else are you suggesting I do?"
As far as reading the entire file into memory:

"I also rewrote the encryption part in the Forms App and got rid of every "large object" (except the bitmap). The input file never gets read into an array or string. The input file is compressed file to file into a compressed file."
I use one list, a list of Color that has 256 members, nothing else. I have used two methods to fill the bitmap:
1 - read each compressed byte using a binary reader
2 - read the entire compressed file into an array
Both of those occur after the bitmap has been created, and there is little difference in performance between them.

The bitmap (saved as a lossless PNG) is nothing more than a container for the Data. It's not necessary, and there are other ways to accomplish the goal, but it's something I want to do. I'll probably have sample code later or tomorrow. I think I see how to post code, but not how to add/include/attach a screenshot. Is that possible ?