Prev: wait for external code to complete before continuing
Next: How do I configure Windows 2003 to get VBScript email with CDO
From: anime on 17 May 2010 12:31 Here is some decoding function, Dim b Function c(d) c=chr(d) End Function b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),...c(000 ),"") Can someone explain this function and purpose of each line before decimal coded ASCII. Also, what need be changed if change Ascii encoding method to HEX encoding? (like this 71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 72 75 20 34 32 34 32 ..)
From: Tom Lavedas on 17 May 2010 13:52 On May 17, 12:31 pm, "anime" <an...(a)nospam.microsoft.news> wrote: > Here is some decoding function, > > Dim b > Function c(d) > c=chr(d) > End Function > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),....c(000 > ),"") > > Can someone explain this function and purpose of each line before decimal > coded ASCII. > Also, what need be changed if change Ascii encoding method to HEX encoding? > (like this 71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 > 72 75 20 34 32 34 32 ..) The function is merely a wrapper that in effect changes the name of the intrinsic CHR() function to the letter C. Otherwise it does NOTHING. To convert it to use HEX strings as input, it could be something like this ... Function c(d) c = chr("&H" & d) End Function However, I wouldn't use the next line to construct an array. Rather, I would just create an input array from a string and cycle through that array to create the output. It makes it far easier to code the input, something like this ... s = "71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 72 75 20 34 " _ & "32 34 32" for each code in split(s) t = t & "," & c(code) next b=split(Mid(t,2), ",") The Mid() part removes an artifact comma from the head of the output string. The loop could just as easily be added to the function to return the desired string (or array) ... Dim b Function decode(d) Dim code, t for each code in split(d) t = t & "," & chr("&H" & CStr(d)) next decode = split(Mid(t,2), ",") End Function b = decode("71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c " _ & "72 75 72 75 69 72 75 72 75 20 34 32 34 32") wsh.echo join(b, ",") _____________________ Tom Lavedas
From: Ceder on 17 May 2010 17:39 "Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:11764ca9-425f-4b35-b010-49cf095f7250(a)y12g2000vbr.googlegroups.com... On May 17, 12:31 pm, "anime" <an...(a)nospam.microsoft.news> wrote: > Here is some decoding function, > > Dim b > Function c(d) > c=chr(d) > End Function > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),...c( 000 > ),"") > > Can someone explain this function and purpose of each line before decimal > coded ASCII. > Also, what need be changed if change Ascii encoding method to HEX encoding? > (like this 71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 > 72 75 20 34 32 34 32 ..) The function is merely a wrapper that in effect changes the name of the intrinsic CHR() function to the letter C. Otherwise it does NOTHING. To convert it to use HEX strings as input, it could be something like this ... Function c(d) c = chr("&H" & d) End Function However, I wouldn't use the next line to construct an array. Rather, I would just create an input array from a string and cycle through that array to create the output. It makes it far easier to code the input, something like this ... s = "71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 72 75 20 34 " _ & "32 34 32" for each code in split(s) t = t & "," & c(code) next b=split(Mid(t,2), ",") The Mid() part removes an artifact comma from the head of the output string. The loop could just as easily be added to the function to return the desired string (or array) ... Dim b Function decode(d) Dim code, t for each code in split(d) t = t & "," & chr("&H" & CStr(d)) next decode = split(Mid(t,2), ",") End Function b = decode("71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c " _ & "72 75 72 75 69 72 75 72 75 20 34 32 34 32") wsh.echo join(b, ",") _____________________ Tom Lavedas -------- a bit more detailed code snippet here: Dim b Function c(d) c=chr(d) End Function b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... ...omitted..........c(000),c(000 ),"") Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) For i = 0 To 67593 f.write(b(i)) Next f.close() ..... ....... ...... This parts recovers encrypted audio file (67593 bytes size). How to modify if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) ?
From: anime on 17 May 2010 19:39 "Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:11764ca9-425f-4b35-b010-49cf095f7250(a)y12g2000vbr.googlegroups.com... On May 17, 12:31 pm, "anime" <an...(a)nospam.microsoft.news> wrote: > Here is some decoding function, > > Dim b > Function c(d) > c=chr(d) > End Function > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),...c( 000 > ),"") > > Can someone explain this function and purpose of each line before decimal > coded ASCII. > Also, what need be changed if change Ascii encoding method to HEX encoding? > (like this 71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 > 72 75 20 34 32 34 32 ..) The function is merely a wrapper that in effect changes the name of the intrinsic CHR() function to the letter C. Otherwise it does NOTHING. To convert it to use HEX strings as input, it could be something like this ... Function c(d) c = chr("&H" & d) End Function However, I wouldn't use the next line to construct an array. Rather, I would just create an input array from a string and cycle through that array to create the output. It makes it far easier to code the input, something like this ... s = "71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c 72 75 72 75 69 72 75 72 75 20 34 " _ & "32 34 32" for each code in split(s) t = t & "," & c(code) next b=split(Mid(t,2), ",") The Mid() part removes an artifact comma from the head of the output string. The loop could just as easily be added to the function to return the desired string (or array) ... Dim b Function decode(d) Dim code, t for each code in split(d) t = t & "," & chr("&H" & CStr(d)) next decode = split(Mid(t,2), ",") End Function b = decode("71 77 74 72 79 72 20 74 75 74 6e 6d 6e 6d 2c " _ & "72 75 72 75 69 72 75 72 75 20 34 32 34 32") wsh.echo join(b, ",") _____________________ Tom Lavedas ---------- a bit more detailed code snippet here: Dim b Function c(d) c=chr(d) End Function b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... ...omitted..........c(000),c(000 ),"") Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) For i = 0 To 67593 f.write(b(i)) Next f.close() ..... ....... ...... This parts recovers encrypted audio file (67593 bytes size). How to modify if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) ?
From: Tom Lavedas on 18 May 2010 08:46
On May 17, 7:39 pm, "anime" <an...(a)nospam.microsoft.com> wrote: {snip} > > a bit more detailed code snippet here: > > Dim b > Function c(d) > c=chr(d) > End Function > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),...... > ..omitted..........c(000),c(000 ),"") > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > For i = 0 To 67593 > f.write(b(i)) > Next > f.close() > .... ....... > ..... > > This parts recovers encrypted audio file (67593 bytes size). How to modify > if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) ? Let me see if I understand correctly. You have a string that contains 67,594 hex values in the %DD format that you want to write to a WAV file? Is that right? Actually, there is an intrinsic VBS function that translates that kind of a string directly - the unescape() function. In such a case, the solution might be as simple as ... s = "%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) f.write unescape(s) f.close() I say *might be* as this is attempting to create a binary file, which can cause the FSO write method some heartburn. Another way is to make use of the ADO binary stream to write the output instead, but I don't have a handy example of that. Plus, if done exactly as I show it, it should work to write binary data. _____________________ Tom Lavedas |