Jump to content

Search the Community

Showing results for tags 'decode'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 7 results

  1. Hello. A couple week ago i've started learning API Interface for different websites. In this fact sometimes you have to encode your "photo" or "document.body" to send request. Functions to encode and decode Base64 was already created by others. Unfortunately i have troubles with running it on Windows R 2008, also speed was terrible. I try to find alternative way to code data. I've read about Microsoft "XMLDOM" and created a one simple function to Encode / Decode data to base64binary, base64url Thanks for Ghads on Wordpress i coverted a part of his lines from VBscript to AutoIT ;============================================================================================================================== ; Function: base64($vCode [, $bEncode = True [, $bUrl = False]]) ; ; Description: Decode or Encode $vData using Microsoft.XMLDOM to Base64Binary or Base64Url. ; IMPORTANT! Encoded base64url is without @LF after 72 lines. Some websites may require this. ; ; Parameter(s): $vData - string or integer | Data to encode or decode. ; $bEncode - boolean | True - encode, False - decode. ; $bUrl - boolean | True - output is will decoded or encoded using base64url shema. ; ; Return Value(s): On Success - Returns output data ; On Failure - Returns 1 - Failed to create object. ; ; Author (s): (Ghads on Wordpress.com), Ascer ;=============================================================================================================================== Func base64($vCode, $bEncode = True, $bUrl = False) Local $oDM = ObjCreate("Microsoft.XMLDOM") If Not IsObj($oDM) Then Return SetError(1, 0, 1) Local $oEL = $oDM.createElement("Tmp") $oEL.DataType = "bin.base64" If $bEncode then $oEL.NodeTypedValue = Binary($vCode) If Not $bUrl Then Return $oEL.Text Return StringReplace(StringReplace(StringReplace($oEL.Text, "+", "-"),"/", "_"), @LF, "") Else If $bUrl Then $vCode = StringReplace(StringReplace($vCode, "-", "+"), "_", "/") $oEL.Text = $vCode Return $oEL.NodeTypedValue EndIf EndFunc ;==>base64
  2. Hello, I am trying to determine the size of attachments from .eml files. The scenario is that I have thousands of emails in .eml file type and need to determine the size of the attachment in some of the emails. I have already determined the number of emails in which there are attachments and the number of attachments per email. Also, emails without attachments. Can anyone shed some light on how i can go about this? BTW, the attachments are now hashed/coded? I don't know how you call it but its just a bunch of characters. File attached is a sample email. Regards, ivan sample.eml
  3. Here's Base91 and Base128 functions I ported from code I found on the net. Quick search of the forum did not pull up anything so don't think these have been posted before. Both just for fun. The base128 is pretty straight forward as its pretty much the same concept as base64 only using 7bits instead of 6, but I thought the base91 was real interesting and Im actually still trying to wrap my head around the algorithm. The functions Ive posted are shortened/combined a bit so if your gonna try and learn the flow I would break it back down to one operation per line. Let me know if you find a string it does not work with. I mainly wanted them for embedding dlls in scripts and the the results are below for a dll that I tested. Have fun! Base91: ; ; #FUNCTION# ==================================================================================================================== ; Name...........: _Base91Encode ; Description ...: Encodes string to Base91 ; Author ........: Brian J Christy (Beege) ; Source ........: http://base91.sourceforge.net/ [Joachim Henke] ; =============================================================================================================================== Func _Base91Encode($sStr) Local $aB91 = StringSplit('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"', '', 2) Local $sEncoded, $b, $n, $v, $aStr = StringToASCIIArray($sStr) For $i = 0 To UBound($aStr) - 1 $b = BitOR($b, BitShift($aStr[$i], ($n * - 1))) $n += 8 If $n > 13 Then $v = BitAND($b, 8191) $s = 13 + ($v <= 88) If $v <= 88 Then $v = BitAND($b, 16383) $b = BitShift($b, $s) $n -= $s $sEncoded &= $aB91[Mod($v, 91)] & $aB91[$v / 91] EndIf Next If $n Then $sEncoded &= $aB91[Mod($b, 91)] If $n > 7 Or $b > 90 Then $sEncoded &= $aB91[$b / 91] EndIf Return $sEncoded EndFunc ;==>_Base91Encode ; #FUNCTION# ==================================================================================================================== ; Name...........: _Base91Encode ; Description ...: Decodes string from Base91 ; Author ........: Brian J Christy (Beege) ; Source ........: http://base91.sourceforge.net/ [Joachim Henke] ; =============================================================================================================================== Func _Base91Decode($sStr) Local $sB91 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"' Local $sDecoded, $n, $c, $b, $v = -1, $aStr = StringSplit($sStr, '', 2) For $i = 0 To UBound($aStr) - 1 $c = StringInStr($sB91, $aStr[$i], 1) - 1 If $v < 0 Then $v = $c Else $v += $c * 91 $b = BitOR($b, BitShift($v, ($n * - 1))) $n += 13 + (BitAND($v, 8191) <= 88) Do $sDecoded &= Chr(BitAND($b, 255)) $b = BitShift($b, 8) $n -= 8 Until Not ($n > 7) $v = -1 EndIf Next If ($v + 1) Then $sDecoded &= Chr(BitAND(BitOR($b, BitShift($v, ($n * - 1))), 255)) Return $sDecoded EndFunc ;==>_Base91Decode Base128: ; #FUNCTION# ==================================================================================================================== ; Name...........: _Base128Encode ; Description ...: Decodes string from Base128 ; Author ........: Brian J Christy (Beege) ; Source ........: https://github.com/seizu/base128/blob/master/base128.php [Erich Pribitzer] ; =============================================================================================================================== Func _Base128Encode($sStr) Local $aB128 = StringSplit('!#$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ', '', 2) Local $sEncoded, $ls, $r, $rs = 7, $aStr = StringToASCIIArray($sStr & ' ') For $i = 0 To UBound($aStr) - 1 If $ls > 7 Then $i -= 1 $ls = 0 $rs = 7 EndIf $nc = BitOR(BitAND(BitShift($aStr[$i], ($ls * -1)), 0x7f), $r) $r = BitAND(BitShift($aStr[$i], $rs), 0x7f) $rs -= 1 $ls += 1 $sEncoded &= $aB128[$nc] Next Return $sEncoded EndFunc ;==>_Base128Encode ; #FUNCTION# ==================================================================================================================== ; Name...........: _Base91Encode ; Description ...: Decodes string from Base128 ; Author ........: Brian J Christy (Beege) ; Source ........: https://github.com/seizu/base128/blob/master/base128.php [Erich Pribitzer] ; =============================================================================================================================== Func _Base128Decode($sStr) Local $sB128 = '!#$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ' Local $sDecoded, $r, $rs = 8, $ls = 7, $aStr = StringSplit($sStr, '', 2) For $i = 0 To UBound($aStr) - 1 $nc = StringInStr($sB128, $aStr[$i], 1) - 1 If $rs > 7 Then $rs = 1 $ls = 7 $r = $nc ContinueLoop EndIf $r1 = $nc $nc = BitOR(BitAND(BitShift($nc, ($ls * -1)), 0xFF), $r) $r = BitShift($r1, $rs) $rs += 1 $ls -= 1 $sDecoded &= Chr($nc) Next Return $sDecoded EndFunc ;==>_Base128Decode Dll Size Tests: Binary Len = 57346 Base64 Len = 38232 Base91 Len = 35180 Base128 Len = 32768 Base91 - Base128.au3 Edit: Fixed Base91 error pointed out by trancexx
  4. Hi, is there a function or a UDF for parsing a hotkey definition string like "^a" or "+!{F1}" ? I´d like to create a settings GUI where users are able to define their custom hotkeys for a specific function and then save it to an ini. Of course, at the next start of the program, these settings have to read and not only the HotkeySet() command needs to be fed with it but also the settings GUI. As I do not want to present the user just the hotkey string but a rather user-friendly display (like checkboxes for the separate modifier keys and a drop down list of supported trigger keys), I need to fiddle on the saved string. I would envision a function that takes a hotkey string and returns for example an array like this: [isCtrl][isAlt][isShift][isWin][triggerKey][isTriggerVirtual]. And of course, there needs to be a function decoding the array back to the respective string representation. Thanks for your hints!
  5. Hello! I've been lurking around for a loooong time... and I decided to finally share a little. I do a lot of internet stuff, mostly machine to machine for work (instrumentation) so I have quite a few "RFC" scripts. Disclaimer these work for me... but I sometime use... "shortcuts" based on my particular requirement. An example, the Base64 encoding snippet might not be too good for binary data. I pad the original data with spaces to avoid the "==" padding of base64. So... first is the base64 encoding snippet. It is not in a function, it was in a sequential program, used only once! It encode $Graph to $SMTPMessage: ; Create the base64 encoding table Dim $Base64EncodingTable[0] For $Cpt = Asc("A") to Asc("Z") _ArrayAdd($Base64EncodingTable, Chr($Cpt)) Next For $Cpt = Asc("a") to Asc("z") _ArrayAdd($Base64EncodingTable, Chr($Cpt)) Next For $Cpt = Asc("0") to Asc("9") _ArrayAdd($Base64EncodingTable, Chr($Cpt)) Next _ArrayAdd($Base64EncodingTable, "+") _ArrayAdd($Base64EncodingTable, "/") ; Pad the SVG Graph to attach with space(s). Lazy way to avoid base64 == pading While Mod(StringLen($Graph), 3) <> 0 $Graph &= " " WEnd ; Start from the first character $Cpt = 1 Do ; Extract the 3 characters to encode $Char1 = Asc(StringMid($Graph, $Cpt, 1)) $Char2 = Asc(StringMid($Graph, $Cpt+1, 1)) $Char3 = Asc(StringMid($Graph, $Cpt+2, 1)) ; Encode them to 4 characters $SMTPMessage &= $Base64EncodingTable[BitShift(BitAND($Char1, 252), 2)] $SMTPMessage &= $Base64EncodingTable[BitShift(BitAND($Char1, 3), -4) + BitShift(BitAND($Char2, 240), 4)] $SMTPMessage &= $Base64EncodingTable[BitShift(BitAND($Char2, 15), -2) + BitShift(BitAND($Char3, 192), 6)] $SMTPMessage &= $Base64EncodingTable[BitAND($Char3, 63)] ; Increment the counter, and if required, add a @CRLF to split in multiples lines $Cpt += 3 If Mod($Cpt, 57) = 1 Then $SMTPMessage &= @CRLF ; Do this until all the graph has been encoded Until $Cpt >= StringLen($Graph) Second... I just finished this one and was allready thinking about sharing it... so it's been encapsulated into function a bit more. I use it to decode email subjects in a system where you can update something by email. I separated the Base64Decode function so it can be grabbed more easily. Please note that it return an hex string so you would still need to convert it if it's a string with BinaryToString or whatever suit your needs. If can be copied as is and runned directly... it include my test strings! (Yes... I'm french!) ; For the $SB_UTF8 and $SB_ANSI Variable #include <StringConstants.au3> ; For _ArrayAdd and _ArraySearch used in the Base64 decoder #include <Array.au3> ; Various test sentences... ;$text = "=?UTF-8?Q?Ce=c3=a7i_est_un_autre_test!_h=c3=a9h=c3=a9!?=" ; Normal UTF-8 ;$text = "=?UTF-8?Q?Encore_=3d_un_autre_test_=c3=a9_?=" ; "=" added ;$text = "=?UTF-8?Q?un_autre_test_=5f_=c3=a9?=" ; "_" added ;$text = "=?UTF-8?B?Q2XDp2kgZXN0IHVuIGF1dHJlIHRlc3QhID0gXyBow6low6kh?=" ; UTF-8 Base64 $text = "=?UTF-8?B?ZcOnaSBlc3QgdW4gYXV0cmUgdGVzdCEgPSBfIGjDqWjDqSE=?=" ; UTF-8 Base64 with padding ;$text = "=?iso-8859-1?Q?Ce=E7i_est_un_test!?=" ; iso-8859-1 MsgBox(0, "", DecodeHeader($text)) Func DecodeHeader($lString) ; Check and store encoding type If StringInStr($lString, "?Q?") Then ; Quoted printable content $lType = "?Q?" ElseIf StringInStr($lString, "?B?") Then ; Base64 encoding $lType = "?B?" Else ; No encoding (or unknown encoding) return($lString) EndIf ; Start of the charset string $lStart = StringInStr($lString, "=?") + 2 ; End of the charset string $lStop = StringInStr($lString, $lType) ; Charset variable, storing "UTF-8" or "iso-8859-1" $lEncoding = StringMid($lString, $lStart, $lStop-$lStart) ; Change encoding type for the BinaryToString flag If $lEncoding = "UTF-8" Then $lEncoding = $SB_UTF8 ElseIf $lEncoding = "iso-8859-1" Then $lEncoding = $SB_ANSI Else MsgBox(0, "", "Unknown character set") Exit EndIf ; Start of the actual encoded content $lStart = $lStop + 3 ; End of the actual encoded content $lStop = StringInStr($lString, "?=") ; Actual content to decode $lString = StringMid($lString, $lStart, $lStop-$lStart) ; For Quoted printable content If $lType == "?Q?" Then ; Restore underscore encoded spaces $lString = StringReplace($lString, "_", " ") ; Starting with the first character of the string $lCpt = 1 ; "=XX" search and convert loop While 1 ; There will be 0 characters to convert in that block unless... $lConvertableLenght = 0 ; That character, and another one 3 bytes over... and the next, and the next... For $lCpt2 = 0 to 100 ; Is equal to "=" If StringMid($lString, $lCpt+($lCpt2*3), 1) == "=" Then ; In that case, yes, we will have to convert 3 more characters $lConvertableLenght += 3 Else ; But if we fail to find or reach the end of a block of encoded characters, exit the search ExitLoop EndIf Next ; If we did in fact find some encoded characters If $lConvertableLenght > 0 Then ; Extract that block of encoded characters $lConvertableString = StringMid($lString, $lCpt, $lConvertableLenght) ; Convert it $lConvertedString = BinaryToString("0x" & StringReplace($lConvertableString, "=", ""), $lEncoding) ; Replace it in the original $lString = StringReplace($lString, $lConvertableString, $lConvertedString) EndIf ; Increment the "=XX" search and convert loop counter $lCpt += 1 ; If we reached the end of the string, exit the "=XX" search and convert loop If $lCpt >= StringLen($lString) Then ExitLoop ; Continue searching in the "=XX" search and convert loop WEnd ; For Base64 encoded strings Else ; Use the separate Base64Decode function $lString = Base64Decode($lString) $lString = BinaryToString($lString, $lEncoding) EndIf return($lString) EndFunc Func Base64Decode($lEncoded) ; Create the base64 encoding table Dim $Base64EncodingTable[0] For $Cpt = Asc("A") to Asc("Z") _ArrayAdd($Base64EncodingTable, Chr($Cpt)) Next For $Cpt = Asc("a") to Asc("z") _ArrayAdd($Base64EncodingTable, Chr($Cpt)) Next For $Cpt = Asc("0") to Asc("9") _ArrayAdd($Base64EncodingTable, Chr($Cpt)) Next _ArrayAdd($Base64EncodingTable, "+") _ArrayAdd($Base64EncodingTable, "/") ; Start from the first character $Cpt = 1 $Decoded = "0x" Do ; Extract the 4 characters to encode $Char1 = StringMid($lEncoded, $Cpt, 1) $Char2 = StringMid($lEncoded, $Cpt+1, 1) $Char3 = StringMid($lEncoded, $Cpt+2, 1) $Char4 = StringMid($lEncoded, $Cpt+3, 1) ; Decode them $Decoded &= Hex(BitShift(_ArraySearch($Base64EncodingTable, $Char1, 0, 0, 1), -2) + BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char2, 0, 0, 1), 48), 4), 2) If $Char3 <> "=" Then $Decoded &= Hex(BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char2, 0, 0, 1), 15), -4) + BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char3, 0, 0, 1), 60), 2), 2) If $Char4 <> "=" Then $Decoded &= Hex(BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char3, 0, 0, 1), 3), -6) + _ArraySearch($Base64EncodingTable, $Char4, 0, 0, 1), 2) ; Increment the counter $Cpt += 4 ; Do this until all the encoded string has been decoded Until $Cpt >= StringLen($lEncoded) return($Decoded) EndFunc Last thing... I may update it into a better format for you, like a standalone telnet program with GUI. It is my telnet options negociations loops. The basic concept is systematically deny all request for special options and keep it "raw". If server says "Will", I reply "Don't". If it says "Do", I reply "Wont"... unless it's the terminal type subnegociation, in which case I reply xterm! $Data for now needs to be Global. You still need to know what you're doing, opening sockets and making a basic communication loop or something. Global $T_Is = Chr(0) Global $T_Send = Chr(1) Global $T_TerminalType = Chr(24) Global $T_SE = Chr(240) Global $T_SB = Chr(250) Global $T_Will = Chr(251) Global $T_Wont = Chr(252) Global $T_Do = Chr(253) Global $T_Dont = Chr(254) Global $T_IAC = Chr(255) Func NegotiateTelnetOptions() $NegotiationCommandsToSendBack = "" While StringInStr($Data, $T_IAC) $IACPosition = StringInStr($Data, $T_IAC) Switch StringMid($Data, $IACPosition+1, 1) Case $T_Will $NegotiationCommandsToSendBack &= CraftReply_CleanUpData($IACPosition, $T_Dont) Case $T_Do If StringMid($Data, $IACPosition+2, 1) = $T_TerminalType Then $NegotiationCommandsToSendBack &= CraftReply_CleanUpData($IACPosition, $T_Will) Else $NegotiationCommandsToSendBack &= CraftReply_CleanUpData($IACPosition, $T_Wont) EndIf Case $T_SB If StringMid($Data, $IACPosition, 6) = ($T_IAC & $T_SB & $T_TerminalType & $T_Send & $T_IAC & $T_SE) Then $NegotiationCommandsToSendBack &= $T_IAC & $T_SB & $T_TerminalType & $T_Is & "xterm" & $T_IAC & $T_SE $Data = StringReplace($Data, StringMid($Data, $IACPosition, 6), "") Else MsgBox(0, "", "Unknown Subnegotiation...") ; Should never happen. Exit EndIf EndSwitch WEnd Return $NegotiationCommandsToSendBack EndFunc Func CraftReply_CleanUpData($IACPosition, $Reply) $PartialCommandToSendBack = $T_IAC & $Reply & StringMid($Data, $IACPosition+2, 1) $Data = StringReplace($Data, StringMid($Data, $IACPosition, 3), "") Return $PartialCommandToSendBack EndFunc
  6. With Autoit 3.3.12.0 a script like the one attached was reading the file "sync_config.db" of google drive, located at %LOCALAPPDATA%\Google\Drive returning into var $sCloudFolder the value "C:\Users\Adams\Google Drive". Now, with Autoit 3.3.14.1, the same script, reading the same file, return into var a long string of characters. I made a text version of the file using copy and paste to observe the correct behavior. I think that the cause is the new method of decoding, but I could not figure out how to solve. #include-once #include <FileConstants.au3> #include <Constants.au3> ; if the Google Drive configuration file exists, it is read If FileExists("sync_config.db") Then ; open the Google Drive configuration file in reading $Handle_GoogleDrive_R = FileOpen("sync_config.db", $FO_READ) If $Handle_GoogleDrive_R = -1 Then ; Check if file opened for reading OK MsgBox(0, "Error", "An error occurred when reading the file " & "sync_config.db") Exit EndIf ; reading Google Drive configuration file $File_GoogleDrive = FileRead($Handle_GoogleDrive_R) ConsoleWrite("$File_GoogleDrive = " & $File_GoogleDrive & @CR) ; find folder path initial position $Start = 1 $Find = "local_sync_root_pathvalue\\?\" $Result = StringInStr($File_GoogleDrive, $Find, 0, 1, $Start) ; find folder path final position $Start = $Result + 29 $Find = "" $Result = StringInStr($File_GoogleDrive, $Find, 0, 1, $Start) $Len = $Result - $Start ; folder for Google Drive Service $sCloudFolder = StringMid($File_GoogleDrive, $Start, $Len) ConsoleWrite("$sCloudFolder = " & $sCloudFolder & @CR) ; close Google Drive configuration file FileClose($Handle_GoogleDrive_R) EndIf sync_config_original.db sync_config_copy.db
  7. I've been working on a huge project. Its a torrent downloader. I can't show the source or anything, sorry guies, that would be frowned upon by the Autoit forum moderators. I won't post a link either but it will be posted on google code in the near future so you can always search for it. I believe that any euthastic torrent downloader will absolutely love it. I would like to have a function to decode bencode torrent files. I've done the research. I need help writing this function. I thank you all in advance and really appreciate any help I recieve from these forums. Features to implement once I can decode bencoded files: (1) Generate magnet links from torrent files. (2) List files inside torrent files. (3) Conviently parse tracker response data for checking torrent trackers for torrent information before adding them to the generated magnet link and passing it to the client which actually downloads the torrent. Spec - Wiki Theory Bittorrent Spec - Bencode - At the bottom of this page there are links to implementations in other languages. Info - Wikipedia - Bencode Bencode Editor - https://sites.google.com/site/ultimasites/bencode-editor - This is allegedly written in Autoit. Though I cannot find the source. I completely rewrote the functions as one function. Its works well but is not exactly what I need. now that I can extract the information I need to associate each type appropiately. For Example: Strings =&gt; Integers Lists =&gt; Strings Dictionaries =&gt; Strings Seeds => 1 Peers => 5 Tracker List => Tracker|Tracker|Tracker This is complicated because lists can be in lists in dictionaries inside of dictionaries or other lists. #include <array.au3> $Timer = TimerInit() Example(@ScriptDir & 'ubuntu-12.04-desktop-i386.iso.torrent') ConsoleWrite(@CRLF & @CRLF & "Time: " & Round(TimerDiff($Timer)/1000, 1) & " second(s)" & @CRLF) Func Example($sFilePath) Local $Bencode = FileRead($sFilePath) Local $aData = _Decode_Bencode($Bencode) _ArrayDisplay($aData) EndFunc Func _Decode_Bencode($sBencoded_Data) Local $iIndex = 0, $sDecoded_Data, $iEndIndex, $iDecoded_Integer, $iDecoded_Dim_0 = 0, $iDecoded_Dim_1 = 0, $iDecoded_Indent = 0 Local $aDecoded_Array[20][20] If Not IsString($sBencoded_Data) Then Return SetError(1, 0, 0) EndIf Local $aBencoded_Data = StringSplit($sBencoded_Data, '', 2) While $iIndex <> UBound($aBencoded_Data, 1) - 1 Switch $aBencoded_Data[$iIndex] Case "e" $iIndex += 1 $iDecoded_Dim_0 += 1 If $iDecoded_Indent <> 0 Then $iDecoded_Indent -= 1 $iDecoded_Dim_1 = $iDecoded_Indent ContinueLoop Case "l" $iIndex += 1 $iDecoded_Dim_1 = $iDecoded_Indent $iDecoded_Dim_0 += 1 $iDecoded_Indent += 1 ContinueLoop Case "d" $iIndex += 1 $iDecoded_Dim_1 = $iDecoded_Indent $iDecoded_Dim_0 += 1 $iDecoded_Indent += 1 ContinueLoop Case "i" $iEndIndex = _ArraySearch($aBencoded_Data, "e", $iIndex, 0, 1) $sDecoded_Data = "" For $i = $iIndex + 1 To $iEndIndex - 1 Step 1 $sDecoded_Data &= $aBencoded_Data[$i] $aBencoded_Data[$i] = "" Next $aDecoded_Array[$iDecoded_Dim_0][$iDecoded_Dim_1] = $sDecoded_Data $iIndex = $iEndIndex - 1 $iDecoded_Dim_1 += 1 Case 0 To 9 $iDecoded_Integer = "" $iEndIndex = _ArraySearch($aBencoded_Data, ":", $iIndex) For $i = $iIndex To $iEndIndex - 1 Step 1 $iDecoded_Integer &= $aBencoded_Data[$i] $aBencoded_Data[$i] = "" Next $sDecoded_Data = "" For $i = $iEndIndex + 1 To $iEndIndex + $iDecoded_Integer Step 1 $sDecoded_Data &= $aBencoded_Data[$i] $aBencoded_Data[$i] = "" Next $aDecoded_Array[$iDecoded_Dim_0][$iDecoded_Dim_1] = $sDecoded_Data $iIndex = $iEndIndex + $iDecoded_Integer $iDecoded_Dim_1 += 1 EndSwitch $iIndex += 1 WEnd Return $aDecoded_Array EndFunc *Edited: Original vbscript - http://demon.tw/my-work/vbs-bencode.html Bencoded Torrent File: ubuntu-12.04-desktop-i386.iso.torrent Thanks in advance!
×
×
  • Create New...