Jump to content

_StringEncrypt


silvano
 Share

Recommended Posts

hi,

I have this script but the return func ($string ) is too long

Are there one func or other script for crypt "test" in a 4 different character string only?

tks

#include <GUIConstants.au3>
#include <String.au3>
$string = _StringEncrypt ( 1, "test", "test")
$WinMain = GuiCreate("testing", 400, 200)
; Creates window
$EditText = GuiCtrlCreateEdit($String,5,5,380,150)

GuiSetState()

While 1
   $msg = GuiGetMsg()

 If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Link to comment
Share on other sites

"test" is only four letters long...do you mean you have some other string? Not sure what you are doing, but maybe this will help:

Func _SplitEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)
    Select
    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)
            Next
            Return $encrypted
        Else
            @error = 1
            ConsoleWriteError("_SplitEncrypt Error --------> Invalid data type." & @CRLF)
        EndIf
    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)
            Next
            Return $encrypted
        Else
            @error = 1
            ConsoleWriteError("_SplitEncrypt Error --------> Invalid data type." & @CRLF)
        EndIf
    Case Else
        @error = 3
        ConsoleWriteError("_SplitEncrypt Error --------> Invalid parameter. Choose 1 to encrypt, 0 to decrypt." & @CRLF)
    EndSelect
EndFunc

But that will only hold 64 elements, or chars if you split it up that way. I don't know what the limits of _StringEncrypt are.

Edit: Prettied it up a bit and added some error messages. NOTE: When encrypting it returns an array with each encrypted character in it's own element, and when decrypting it returns a string.

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

Hmm, maybe you just want to display the encrypted text in the editbox? I really don't know what want to do, perhaps elaborate on your idea

#include <GUIConstants.au3>
#include <String.au3>
$string = _StringEncrypt ( 1, "test", "test")
$WinMain = GuiCreate("testing", 400, 200)
$EditText = GuiCtrlCreateEdit($String,5,5,380,150)
;\/ this sets the edit to the encrypted text
GUIctrlsetdata($edittext,$string)

GuiSetState()

While 1
   $msg = GuiGetMsg()

 If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Awaiting Diablo III..

Link to comment
Share on other sites

tks Mike,

split is very hot idea, but when I call the func the return is null

$c = _SplitEncrypt(1, "test", "passtest")
MsgBox(0,"",$c)

hi, _kurt

the problem not is editbox, it's only for me... (copy&paste)

the problem is the func _crypt.

I must crypt/decrypt a string e.g.: "testformycrypt123" but _crypt func return

a much long one string

I would like to crypt string in the same length to original string

sorry for my bad english and thanks a lot

Link to comment
Share on other sites

NOTE: When encrypting it returns an array with each encrypted character in it's own element, and when decrypting it returns a string.

ie. use _ArrayDisplay if you want to see the encrypted array. This doesn't make the encryption any shorter, it just splits it up into elements.

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
 Share

  • Recently Browsing   0 members

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