Jump to content



Recommended Posts

I've made a sort of useless function, but I did find that in some cases it is actually significantly faster than _StringEncrypt.

; Function Name:    _SplitEncrypt()
; Description:      RC4 Based string encryption using arrays
; Parameter(s):     $i_Encrypt - 1 to encrypt, 0 to decrypt
;                   $s_EncryptText - string to encrypt
;                   $s_EncryptPassword - string to use as an encryption password
;                   $i_EncryptLevel - integer to use as number of times to encrypt string
; Requirement(s):   #include <String.au3>
; Return Value(s):  On Success - Returns the string encrypted/decrypted (blank) times with (blank) password
;                       in the form of an array for encrypting, and a string for decrypting
;                   On Failure - Returns a blank string and sets @error = 1 for invalid data type input,
;                                   or sets @error = 3 for an invalid encryption index
; Author(s):        Radagast
;                       Author of _StringEncrypt - Wes Wolfe-Wolvereness <Weswolf at aol dot com>

Func _SplitEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)
    Case $i_Encrypt = 1
        If IsString($s_EncryptText) Then
            $string = StringSplit($s_EncryptText, "")
            $num = UBound($string) - 1
            Dim $encrypted[$num]
            For $i = 1 to $num
                $encrypted[$i - 1] = _StringEncrypt(1, $string[$i], $s_EncryptPassword, $i_EncryptLevel)
            Return $encrypted
            @error = 1
            ConsoleWriteError("_SplitEncrypt Error --------> Invalid data type." & @CRLF)
    Case $i_Encrypt = 0
        If IsArray($s_EncryptText) Then
            $encrypted = ""
            $num = UBound($s_EncryptText) - 1
            For $i = 0 to $num
                $encrypted &= _StringEncrypt(0, $s_EncryptText[$i], $s_EncryptPassword, $i_EncryptLevel)
            Return $encrypted
            @error = 1
            ConsoleWriteError("_SplitEncrypt Error --------> Invalid data type." & @CRLF)
    Case Else
        @error = 3
        ConsoleWriteError("_SplitEncrypt Error --------> Invalid parameter. Choose 1 to encrypt, 0 to decrypt." & @CRLF)

Now, when you have a long string like "testing1testing1testing1testing1", and you run that through both functions, _StringEncrypt is quicker. But in the case of "testing1testing1testing1testing1" run through _StringEncrypt and an array with each element as "testing1" run through _SplitEncrypt, _SplitEncrypt was up to 200% faster. I don't know if this has any actual application, but I just thought I'd share a slow day at the office's afternoon work.

Edit: First example script ever posted......no paddling! ....please....

Also added comments at the beginning.

Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...