Sign in to follow this  
Followers 0
carl1905

StringToBinary with _stringbetween

3 posts in this topic

#1 ·  Posted (edited)

Hi, I have in trouble converting *.txt to original binary format. I attached my sample text file.

The one what I want is

1) If text contains "[" and "]" then Split text into array.

2) Convert StringToBinary btw "[" and "]" 

3) Convert other strings(Japanese) to Shift-JIS.

For example, like this.

$text_unicode = "すばらしい!<lf>すばらしいです、[010004300020FF]さん!"

[010004300020FF] to 0x010004300020FF and other text values into Shift-JIS.

$result = 0x82B782CE82E782B582A282C582B78141010004300020FF82B382F18149

Result in hex editor

My problem is related with this post. [Solved] Extracting text from string and reinsert it.

 

Edited by carl1905
No ones reply

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How can I convert 020000300020FF to 0x02 0x00 0x00 0x30 0x00 0x20 0xFF..? Can someone help me?

$Newtext &= Binary("0x"&$split[$i][0])

My script always returns 

$split[$i][0] = 020000300020FF to 0x30 0x32 0x30 0x30 0x30 0x30 0x33 0x30 0x30 0x30 0x32 0x30 0x46 0x46

 

Edited by carl1905

Share this post


Link to post
Share on other sites

Ok.. it seems that

$Newtext &= _HexToString($split[$i][0])

Convert 

1F040017300020FF to 1F0400173000203F

By the way why FF is converted to 3F?

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • carl1905
      By carl1905
      Hi, I'm looking for a way to convert string to original binary.
      The reversal process was already solved. BinaryToString for unsupported language
      How can I convert unicode string to original binary format(Shift-JIS)?
      $text(Unicode) = "データのダウンロードに失敗しました。" = "0xFFFEC730FC30BF306E30C030A630F330ED30FC30C9306B303159576557307E3057305F300230" <Original form> $stringToBinary(Shift-JIS) = "0x8366815B835E82CC835F83458393838D815B836882C98EB8947382B582DC82B582BD8142"  
    • ViciousXUSMC
      By ViciousXUSMC
      So I am trying to write a script that can take the current computer name and write it to a registry key.
      This key uses REG_BINARY type of key and looks like this:
      Value 1 Name: LocalName Type: REG_BINARY Data: 00000000 54 4f 55 47 48 42 4f 4f - 4b 36 30 39 38 00 00 00 TOUGHBOOK6098... 00000010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000020 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000030 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000040 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000050 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000060 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000070 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000080 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000090 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000a0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000b0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000c0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000d0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000e0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000f0 00 00 00 00 00 00 00 00 - ........ Its apparently very important that all the ending 00's are in there I found this out as I was working on some other keys that had to do with security settings, and if the key was say 01 00 00 putting any less or any extra ending zeros would cause the change in the regsitry to not effect the software.
      So what I am attempting to do is use the @ComputerName macro and plug it into a StringtoBinary() function and then write it to the registry.
      The challenge I face is how to fill in the entire binary value for the registry key and not just the converted strings value.
      I wonder if there is some easy code to do that.  I imagine there must be a few ways but I am looking for the most straight forward/easiest. 
      Also on a side note, instead of using RegWrite is there a way to create a .REG file that I can call from CMD with Reg Import?
      This is being done at an enterprise level and the users do not have access to write to the registry, but they can import a reg file via .bat or in my case a Autoit .exe with @ComSpec
      Currently I am importing all the "static" keys I need for configuration, but computer name is dynamic so that is why I am trying to find a way to use the @ComputerName macro to insert that value.
      Regards,
    • Rickname
      By Rickname
      The StringToByte function , I expected to return 0s and 1s as strings displayed, but in fact it returns in hex if Im not wrong like 0xH3J4H....
      How can I make to return to me the expression of a string in bits ?