topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • July 22, 2019, 01:06 PM
  • Proudly celebrating 13 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ashecorven [ switch to compact view ]

Pages: [1]
1
Lifeweaver, thank you, it's fantastic. Everything seems to be working fantastically.

Really appreciated.

I'm not sure how this is done, but I think this should be added to the list of software available on the site!

2
Hello again,

Thanks for the quick response!

HEX to binary and vice-versa shouldn't have anything to do with ASCII. At the moment, both binary and HEX are being read in as ASCII (converting HEX to * == converting text to *) and (converting binary to * == converting text to *).

Examples.
11111111 00000000 00000000 11111111 should convert to FF00 00FF, but output is 31 31 31 31 31 31 31 31 20 30 30 30 30 30 30 30 30 20 30 30 30 30 30 30 30 30 20 31 31 31 31 31 31 31 31.

E.g. FF00 00FF should convert to 11111111 00000000 00000000 11111111, but output is 01000110 01000110 00110000 00110000 00100000 00110000 00110000 01000110 01000110.

I think a quick way to check if things are being read in correctly would be HEX->HEX, Binary->binary, text->text, etc. At the moment they're not working.

3
Thank you for taking the time on this, the way it works/ease of use is fantastic. Thanks for the copy to input and clipboard! The Smart Convert is great :)

Unfortunately some of the conversions aren't working correctly. Seems as though input is always (AFAICS) being read as ASCII.
For example:
- Anything to/from decimal [decimal 1 gives HEX 31 and binary 00110001] [decimal 255 gives decimal 50 53 53]
- HEX to binary is actually doing text to binary.
- Binary to HEX is actually doing text to hex.

Haven't checked B64, ROT13 and URLenc but didn't see anything unusual.

Also is it possible to have it encode to all types at once? i.e. Choose only the input type and it outputs to multiple text boxes, then each could be copied to clipboard, input box, etc.

Also I slightly altered just one thing in your script as any hex output would be missing a space after the 16th value.

Spoiler
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance ignore

Help(wParam, lParam, Msg)
{
  MouseGetPos,,,, OutputVarControl

  IfEqual, OutputVarControl, Button1
Help := "Will try to convert the input multiple times if detected as Hex/Binary."
  else IfEqual, OutputVarControl, Button2
Help := "Will replace your current clipboard"

  ToolTip % Help
}

determineEncoding(string)
{
  BINARY_REGEX := "^(\d{8}\s?)*$"
  ;~ BASE64_REGEX := "^([A-Za-z0-9+\/]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)$"
  HEX_REGEX := "^([0-9A-Fa-f]{2}\s?)+$"
  ;~ DECIMAL_REGEX := "^([0-9]{2,3}\s?)+$"
 
  if(RegExMatch(string, BINARY_REGEX))
    return "Binary"
  else if(RegExMatch(string, HEX_REGEX))
    return "Hex"
  else
    return false
}

StrPutVar(string, ByRef var, encoding)
{
    ; Ensure capacity.
    VarSetCapacity( var, StrPut(string, encoding)
        ; StrPut returns char count, but VarSetCapacity needs bytes.
        * ((encoding="utf-16"||encoding="cp1200") ? 2 : 1) )
    ; Copy or convert the string.
    return StrPut(string, &var, encoding)
}

determineEncodingFlag(encoding, crypt)
{
  if(crypt = "encrypt")
  {
    if(encoding = "Binary")
      return 0x00000002
    else if(encoding = "BASE64")
      return 0x40000001
    else if(encoding = "Hex")
      return 0x00000004
  }
  else if (crypt = "decrypt")
  {
    if(encoding = "Binary")
      return 0x00000002
    else if(encoding = "BASE64")
      return 0x00000006
    else if(encoding = "Hex")
      return 0x00000008
  }
}

encodeUTF8( ByRef OutData, InData, inputEncoding)
{
  if(inputEncoding = "Binary")
  {
    OutData := TxtToBin(InData)
    return StrLen(OutData)
  }
 
  encoding := determineEncodingFlag(inputEncoding, "encrypt")
  InDataLen := StrPutVar(InData, InData, "UTF-8") - 1
  DllCall( "Crypt32.dll\CryptBinaryToStringW", UInt,&InData, UInt,InDataLen, UInt,encoding, UInt,0, UIntP,TChars, "CDECL Int" )
  VarSetCapacity( OutData, Req := TChars * ( A_IsUnicode ? 2 : 1 ), 0 )
  DllCall( "Crypt32.dll\CryptBinaryToStringW", UInt,&InData, UInt,InDataLen, UInt,encoding, Str,OutData, UIntP,Req, "CDECL Int" )
 
  if(inputEncoding = "Hex")
  {
    StringReplace, OutData, OutData, %A_Space%%A_Space%, %A_Space%, All
   
    ; Not sure if I really want to remove the newlines for hex
    StringReplace, OutData, OutData, `r`n, %A_Space%, All
  }
 
  Return TChars
}

decodeUTF8( ByRef OutData, InData, inputEncoding)
{
  if(inputEncoding = "Binary")
  {
    OutData := BinToTxt(InData)
    return StrLen(OutData)
  }
 
  encoding := determineEncodingFlag(inputEncoding, "decrypt")
  DllCall( "Crypt32.dll\CryptStringToBinaryW", UInt,&InData, UInt,StrLen(InData), UInt,encoding, UInt,0, UIntP,Bytes, Int,0, Int,0, "CDECL Int" )
  VarSetCapacity( OutData, Req := Bytes * ( A_IsUnicode ? 2 : 1 ), 0 )
  DllCall( "Crypt32.dll\CryptStringToBinaryW", UInt,&InData, UInt,StrLen(InData), UInt,encoding, Str,OutData, UIntP,Req, Int,0, Int,0, "CDECL Int" )
  OutData := StrGet(&OutData, "cp0")
  Return Bytes
}

TxtToBin(txt)
{ ; http://www.autohotkey.com/board/topic/7835-ascii-binary-converter/?p=48740
  Loop Parse, txt
  {
    Loop 8
    {
      bin := bin (Asc(A_LoopField) >> (8 - A_Index) & 1)
    }
    bin .= " "
  }
   Return bin
}

BinToTxt(bin)
{ ; http://www.autohotkey.com/board/topic/7835-ascii-binary-converter/?p=48740
   StringReplace, bin, bin, %A_Space%,,All
   Loop Parse, bin
   {
      x += x + (A_LoopField = "1")

      If !Mod(A_Index,8)
      {
         txt := txt Chr(x)
         x = 0
      }
   }
   Return txt
}

Rot13(string)
{ ; from LinearSpoon's Translation of The Worlds Shortest C Implementation of Rot13 http://rosettacode.org/wiki/Rot-13#AutoHotkey
  Output := ""
  Loop, Parse, string
  {
    a := ~Asc(A_LoopField)
    Output .= Chr(~a-1//(~(a|32)//13*2-11)*13)
  }
  return Output
}

ascii2Decimal(string)
{
  encoding := ""
  Loop, Parse, string
  {
    encoding .= Asc(A_LoopField) . " "
  }
  return SubStr(encoding, 1, StrLen(encoding) - 1)
}

decimal2Ascii(string)
{
  decoding := ""
  Loop, Parse, string, %A_Space%
  {
    decoding .= Chr(A_LoopField)
  }
  return decoding
}

uriEncode(str)
{ ; v 0.3 / (w) 24.06.2008 by derRaphael / zLib-Style release http://www.autohotkey.com/board/topic/6199-url-encoding/?p=193258
b_Format := A_FormatInteger
data := ""
SetFormat,Integer,H
Loop,Parse,str
if ((Asc(A_LoopField)>0x7f) || (Asc(A_LoopField)<0x30) || (asc(A_LoopField)=0x3d))
data .= "%" . ((StrLen(c:=SubStr(ASC(A_LoopField),3))<2) ? "0" . c : c)
Else
data .= A_LoopField
SetFormat,Integer,%b_format%
return data
}

uriDecode(str)
{ ; v 0.1 / (w) 28.06.2008 by derRaphael / zLib-Style release http://www.autohotkey.com/board/topic/6199-url-encoding/?p=193258
Loop,Parse,str,`%
txt := (A_Index=1) ? A_LoopField : txt chr("0x" substr(A_LoopField,1,2)) SubStr(A_LoopField,3)
return txt
}

convertInputToText(string, inputEncoding)
{
  if(inputEncoding = "BASE64")
    decodeUTF8(decoded, string, "Base64")
  else if(inputEncoding = "Binary")
    decodeUTF8(decoded, string, "Binary")
  else if(inputEncoding = "Decimal")
    return decimal2Ascii(string)
  else if(inputEncoding = "Hex")
    decodeUTF8(decoded, string, "Hex")
  else if(inputEncoding = "ROT13")
    return Rot13(string)
  else if(inputEncoding = "URI Encoded")
    return uriDecode(string)
 
  return decoded
}

convertInputToOutputEncoding(inputEncoding, string, outputEncoding)
{
  if(outputEncoding = "BASE64")
    encodeUTF8(encoded, string, "Base64")
  else if(outputEncoding = "Binary")
    encodeUTF8(encoded, string, "Binary")
  else if(outputEncoding = "Decimal")
    return ascii2Decimal(string)
  else if(outputEncoding = "Hex")
    encodeUTF8(encoded, string, "Hex")
  else if(outputEncoding = "ROT13")
    return Rot13(string)
  else if(outputEncoding = "URI Encoded")
    return uriEncode(string)
  else if(outputEncoding = "")
    return convertInputToText(string, inputEncoding)
  else if(outputEncoding = "Text")
    return convertInputToText(string, inputEncoding)
 
  return encoded
}

Gui, Add, Text, x22 y20 w40 h20 , Input:
Gui, Add, DropDownList, x92 y20 w280 h20 vinputEncoding Choose1 R9, Text|BASE64|Binary|Decimal|Hex|ROT13|URI Encoded
;~ Gui, Add, Button, x452 y10 w110 h40 vguessEncoding gguessEncoding , Guess encoding
Gui, Add, Edit, x32 y60 w530 h270 vconverterInput ,

Gui, Add, Text, x22 y340 w40 h20 , Output:
Gui, Add, DropDownList, x92 y340 w280 h20 voutputEncoding goutputEncoding Choose1 R9, Text|BASE64|Binary|Decimal|Hex|ROT13|URI Encoded
Gui, Add, CheckBox, x462 y340 w100 h20 hwndsmartConvertHwnd vsmartConvert , Smart Convert?
Gui, Add, Edit, x32 y370 w530 h270 vconverterOutput ,
Gui, Add, Button, x32 y650 w140 h30 gcopyOutputToClipboard hwndcopyToClipboardHwnd , Copy Output to Clipboard
Gui, Add, Button, x242 y650 w150 h30 gcopyOutputToInput , Copy Output to Input
Gui, Add, Button, x462 y650 w100 h30 vencode gencode , Encode

; Generated using SmartGUI Creator 4.0
Gui, Show, xCenter yCenter h705 w585, Converter
OnMessage(0x200, "Help")
Return

GuiClose:
ExitApp

encode:
Gui, Submit, nohide
GuiControlGet, inputEncoding,, inputEncoding
GuiControlGet, converterInput,, converterInput
GuiControlGet, outputEncoding,, outputEncoding
GuiControlGet, smartConvertEnabled,, smartConvert

outputText := convertInputToOutputEncoding(inputEncoding, converterInput, outputEncoding)

if(smartConvertEnabled)
{
  result := DetermineEncoding(outputText)
  While result != false && result != outputEncoding
  {
    outputText := convertInputToText(outputText, result)
    result := DetermineEncoding(outputText)
  }
}

Guicontrol,, converterOutput, %outputText%
return

copyOutputToClipboard:
GuiControlGet, ClipBoard,, converterOutput
return

copyOutputToInput:
GuiControlGet, currentOutputEncoding,, outputEncoding
GuiControlGet, output,, converterOutput
Guicontrol,, converterInput, %output%
Guicontrol,, converterOutput
GuiControl, ChooseString, inputEncoding, %currentOutputEncoding%
GuiControl, Choose, outputEncoding, 1
GuiControl, Enable, smartConvert
return

outputEncoding:
GuiControlGet, outputEncoding,, outputEncoding
if(outputEncoding != "Text")
{
  GuiControl,, smartConvert, 0
  GuiControl, Disable, smartConvert
}
else if(outputEncoding = "Text")
{
  GuiControl, Enable, smartConvert
}
return


4
lifeweaver!

Have only just seen your responses. Thank you.

About to play with it now.

5
Hello again, any progress?

7
Coding Snacks / Re: Update of NirSoft's ZipInstaller
« on: April 02, 2015, 12:10 AM »
Not 100% how it works here, has this been picked up or should I be promoting the idea more?

8
Coding Snacks / Re: Update of NirSoft's ZipInstaller
« on: February 07, 2015, 09:35 PM »
Guess it would make sense to make the context menu entry available on executables directly as well as have an option to add installed programme to startup.

9
Coding Snacks / Re: Update of NirSoft's ZipInstaller
« on: February 07, 2015, 01:19 PM »
Anyone interested?  :-[

10
You mentioned malware.  However, please keep in mind that whatever I come up with isn't going to handle any sort of binary file input (if that's what you envisioned).

Hehehe, no, that would be a BIG ask. I'm more than happy with the programmes I use and one day hope I know how to use half of the functionality they provide.

Good to hear.  I like the way that app turned out.  If you're brave, feel free to try the beta.

Trying it out now.

11
Champion!

Look forward to it.

"Patience is the art of hoping!"

BTW: Have been using epCheck for some time now.

12
Exactly, it's not fun converting each byte in binary to ASCII. Notepad++ isn't the answer. Need a new tool.

Easy, Malware analysis.

I need something like this quite often, this should also explain the need to be offline at times.

13
That's step one, now do binary to ASCII...

14
Yes, npp has plugins to do it (TextFX being the main one I've used). I've just played with it again to see if anything has changed and it is still messy, does not work properly nor provide multiple direction conversion.

In npp, converting the following is not fun.

30 31 30 30 31 30 30 31 20 30 31 31 30 30 31 31 30 20 30 30 31 30 30 30 30 30 20 30 31 31 31 30 31 30 30 20 30 31 31 30 31 30 30 30 20 30 31 31 30 31 30 30 31 20 30 31 31 31 30 30 31 31 20 30 30 31 30 30 30 30 30 20 30 31 31 31 30 31 31 31 20 30 31 31 30 30 30 30 31 20 30 31 31 31 30 30 31 31 20 30 30 31 30 30 30 30 30 20 30 31 31 30 31 30 30 31 20 30 31 31 30 31 31 31 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 30 30 31 20 30 30 31 30 30 30 30 30 20 30 31 31 31 30 31 30 31 20 30 31 31 31 30 31 30 30 20 30 31 31 30 31 30 30 31 20 30 31 31 30 31 31 30 30 20 30 31 31 30 31 30 30 31 20 30 31 31 31 30 31 30 30 20 30 31 31 31 31 30 30 31 20 30 30 31 30 30 30 30 30 20 30 31 31 30 31 30 31 30 20 30 31 31 31 30 31 30 31 20 30 31 31 31 30 30 31 31 20 30 31 31 31 30 31 30 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 31 31 30 20 30 31 31 30 31 31 31 31 20 30 31 31 31 30 30 31 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 30 31 31 20 30 31 31 30 31 31 31 31 20 30 31 31 30 31 31 31 30 20 30 31 31 31 30 31 31 30 20 30 31 31 30 30 31 30 31 20 30 31 31 31 30 30 31 30 20 30 31 31 31 30 30 31 31 20 30 31 31 30 31 30 30 31 20 30 31 31 30 31 31 31 31 20 30 31 31 30 31 31 31 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 31 30 30 31 20 30 31 31 31 30 31 30 30 20 30 30 31 30 30 30 30 30 20 30 31 31 31 30 31 31 31 20 30 31 31 30 31 31 31 31 20 30 31 31 31 30 31 30 31 20 30 31 31 30 31 31 30 30 20 30 31 31 30 30 31 30 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 30 31 30 20 30 31 31 30 30 31 30 31 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 30 30 31 20 30 30 31 30 30 30 30 30 20 30 31 31 30 31 30 30 30 20 30 31 31 30 30 31 30 31 20 30 31 31 30 31 31 30 30 20 30 31 31 30 31 31 30 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 31 31 31 31 20 30 31 31 30 30 31 31 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 30 30 31 20 30 30 31 30 30 30 30 30 20 30 31 31 30 31 31 30 30 20 30 31 31 30 31 31 31 31 20 30 31 31 31 30 31 30 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 31 30 31 20 30 31 31 30 30 30 30 31 20 30 31 31 31 30 30 31 31 20 30 31 31 30 31 30 30 31 20 30 31 31 30 30 31 30 31 20 30 31 31 31 30 30 31 30 20 30 30 31 30 30 30 30 30 20 30 31 31 30 30 30 30 31 20 30 31 31 30 31 31 31 30 20 30 31 31 30 30 31 30 30 20 30 30 31 30 30 30 30 30 20 30 31 31 31 30 30 30 30 20 30 31 31 30 30 31 30 31 20 30 31 31 31 30 30 31 30 20 30 31 31 30 30 31 31 30 20 30 31 31 30 30 31 30 31 20 30 31 31 30 30 30 31 31 20 30 31 31 31 30 31 30 30 20 30 30 31 30 30 30 30 31

A simple utility just to handle conversion would be welcome and as far as I can see, does not exist.

Functionality like ASCII to Hex ...and other free text conversion tools would be nice.

15
Coding Snacks / Re: Update of NirSoft's ZipInstaller
« on: February 05, 2015, 11:06 AM »
I'm curious why the utility has not been kept up to date.  It seems like a cool idea.  I wonder if 64 bit stuff coming on has complicated things, along with the Programs and Features etc..

Glad you agree. :Thmbsup: Really hope this gets off the ground.
Scott Hanselman still recommends ZipInstaller, would be great if there was an updated version to take over and do things right.
Scott Hanselman's 2014 Ultimate Developer and Power Users Tool List for Windows

I don't see 64-bit being a problem (unless it's something other than detection you're discussing) ZipInstaller has had no issue with them (Regshot or RBTray for example). Info on whether it's 32 or 64-bit is in the File Header, Machine=014C (32-bit) or Machine=8664 (64-bit) and can be detected with 'file' or 'dumpbin'.

If there are multiple executables then the user can be prompted to choose which. Solves issue if there are both 32 and 64-bit exes in the zip (again, Regshot or RBTray for example).

Also I can't see Programmes and Features being a problem if the user can edit the detected information (or lack thereof - FastStone Capture v5.3 for example) as this would eliminate all the problems it currently has.

/edit: fixed examples

16
Coding Snacks / Re: Update of NirSoft's ZipInstaller
« on: February 05, 2015, 09:36 AM »
for portable software, there are several ways of handling the 'install' process, indeed often just an unzip/create shortcut(s)

This is exactly what ZipInstaller is for (not just portable apps though), it's a quick installation process that adds an entry into Programmes & Features. Programmes installed this way have always worked even for quite large installations like the full cmder, however the entry in Programmes & Features may not be correct (see original post).

17
Coding Snacks / Re: Update of NirSoft's ZipInstaller
« on: February 04, 2015, 08:50 AM »
Hey Ath, thanks.

Does it have the same functionality to right click an archive and install it? (If it's listed in features I don't see it, or assume it's something else)

/edit: made less confusing.

18
I'm shocked I've not been able to find a programme to convert between these schemes.

I can only find online converters that feature more than a few encoding schemes.
ASCII to Hex ...and other free text conversion tools
swiss converter tool

I haven't coded in such an age, but it seems like all of the conversion code is already out there, just needs to be put into a nice little interface.

Would love to see this! :-*

/edit: links now link

19
Coding Snacks / Update of NirSoft's ZipInstaller
« on: February 04, 2015, 06:43 AM »
Hi,

Just found this site, so many useful tools and it really looks like a wonderful community.

Searched to see if the programme I've been looking for has already been written but had no luck.

[http://www.nirsoft.net/utils/zipinst.html]
"The ZipInstaller utility installs and uninstalls applications and utilities that do not provide an internal installation program. It automatically extracts all files from the Zip file, copies them to the destination folder you select, creates shortcuts in the start menu and in your desktop, and adds an uninstall module to allow you to automatically remove the software in the future."

I've been using it for quite a long time, it's a simple app that is invoked from the context menu of archives.

Unfortunately there has always been a problem with it. I contacted Nir to see if an update is possible but have had no response.

- The majority of programmes I want to install in this fashion don't include correct information if any (or ZipInstaller is not picking it up). ZipInstaller does not allow the user to alter the detected Company/Author, Product Name, version, description - before clicking Install, resulting in strange or blank entries in Programmes and Features (not at all desirable).

Would also be a thousand times better if it
- Supported other archive formats
- Detected whether programme is 32 or 64-bit and installed to Program Files or Program Files (x86) accordingly
- Had it's own installer!

What do you all think?

Pages: [1]