Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-09-2024, 01:20
eychei eychei is offline
Friend
 
Join Date: Mar 2018
Posts: 58
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 34
Thanks Rcvd at 10 Times in 10 Posts
eychei Reputation: 0
Question DES-X Encryption slow / Help needed

Hi everyone,

I did write a small vb.net program to encrypt and decrypt DESX.
Its actually nearly the same as DES but with an additional input and output XOR with two extra keys.

wo8Bl.png

So when I decrypt files it easy really fast taking around 10sec for 100mb.
This is because I can decrypt the complete file first without needing to go from one block to the next.

But when I encrypt files I need to chain 8 byte sized chunks in serial.


My vb.net code looks like this:

Code:
 'DES-X Start
            Dim xor_in_array As Byte() = XORarrayValues(input_whitener_array, ByteToEncrypt)
            Dim ciphertext As Byte() = New Byte(ByteToEncrypt.Length - 1) {}
            Dim ms As New MemoryStream
            Dim cs As New CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write)
            Dim cut_bytes() As Byte = New Byte(8 - 1) {}
            For i = 0 To (xor_in_array.Length / 8) - 1

                Array.Copy(xor_in_array, CInt(i) * 8, cut_bytes, 0, 8)
                If i = 0 Then
                    Dim xor_iv = XORarrayValues(cut_bytes, Var.iv)
                    ms.Position = 0
                    cs.Write(xor_iv, 0, xor_iv.Length)
                    Dim des_xor_iv = ms.ToArray()
                    Dim xor_out = XORarrayValues(Var.output_whitener, des_xor_iv)
                    Array.Copy(xor_out, 0, ciphertext, CInt(i) * 8, 8)

                Else
                    Dim ciphertext_used() As Byte = New Byte(8 - 1) {}
                    Array.Copy(ciphertext, CInt(i - 1) * 8, ciphertext_used, 0, 8)
                    Dim xor_ciphertext_used = XORarrayValues(cut_bytes, ciphertext_used)
                    ms.Position = 0
                    cs.Write(xor_ciphertext_used, 0, xor_ciphertext_used.Length)
                    Dim des_xor_out = ms.ToArray()
                    Dim xor_out = XORarrayValues(Var.output_whitener, des_xor_out)
                    For j = 0 To xor_out.Length - 1
                        ciphertext(i * 8 + j) = xor_out(j)

                    Next
                    'Array.Copy(xor_out, 0, ciphertext, CInt(i) * 8, 8)
                    'ciphertext = ciphertext.Concat(xor_out).ToArray()



                End If
So I tried different approaches in appending the ciphertext at the end to a bte array so i can write it to file afterwards.
It does not change in speed if I use array.copy / concat or for loop copy.
I also tried with creating 4-8 parallel threads. While this reduces the time needed for encryption, it is still slow for very big files.


How can I increase speed for the encryption algorithm? Hope someone has a solution.

Thx.

-e
Reply With Quote
 

Tags
des, desx

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is slow link to this forum Neptune General Discussion 7 12-31-2012 02:54
ExeTools is getting slow... baatazu General Discussion 19 07-29-2005 22:11
Emule is so slow for me Rhodium General Discussion 12 04-10-2005 05:47


All times are GMT +8. The time now is 00:05.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )