<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Typecasting String to Hex/Dec/Oct in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546943#M155049</link>
    <description>&lt;P&gt;Thank you for the super quick response! This returns "10" which is the value of "a" in decimal. If you try converting anything that's beyond the hex range (0-9a-f) then you will get nothing in return.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Apr 2021 21:45:25 GMT</pubDate>
    <dc:creator>juanfiguera</dc:creator>
    <dc:date>2021-04-06T21:45:25Z</dc:date>
    <item>
      <title>Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546940#M155047</link>
      <description>&lt;P&gt;I'm looking for a way of typecasting ASCII characters (A,B,C,D,etc) into their decimal or hexadecimal formats.&lt;/P&gt;&lt;P&gt;I've tried&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;|makeresults
|eval fielda="a"
|eval char=printf("%d",fielda)
|table fielda char&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This gives me an empty field for "char".&lt;/P&gt;&lt;P&gt;Then tried tonumber() and tostring() but both require strings which are numbers, not letters and so they come back with Null values.&lt;/P&gt;&lt;P&gt;Is there a way of typecasting ASCII to Hex/Dec/Oct?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 21:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546940#M155047</guid>
      <dc:creator>juanfiguera</dc:creator>
      <dc:date>2021-04-06T21:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546942#M155048</link>
      <description>&lt;LI-CODE lang="markup"&gt;|makeresults
|eval fielda="a"
|eval char=tonumber(fielda,16)
|table fielda char&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Apr 2021 21:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546942#M155048</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-06T21:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546943#M155049</link>
      <description>&lt;P&gt;Thank you for the super quick response! This returns "10" which is the value of "a" in decimal. If you try converting anything that's beyond the hex range (0-9a-f) then you will get nothing in return.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 21:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546943#M155049</guid>
      <dc:creator>juanfiguera</dc:creator>
      <dc:date>2021-04-06T21:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546947#M155051</link>
      <description>&lt;P&gt;If you want to convert letters to their ascii code equivalents, you could try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults
|eval fielda="a"
|eval char=printf("0x%X",tonumber(fielda,36)+55)
|table fielda char&lt;/LI-CODE&gt;&lt;P&gt;This issue with this is that it doesn't work consistently for all letters, indeed, the values returned are for the uppercase letters even if a lowercase letter is used. To get the right value returned, you would have to play about with the value being added for different ranges of letters&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 22:31:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546947#M155051</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-06T22:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546948#M155052</link>
      <description>&lt;P&gt;Not aware of a way other than writing python, but you can achieve limited results with a simple macro that encapsulates&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;NB: EDITED TO FIX UP typo&lt;/FONT&gt; identified by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/234377"&gt;@user_bee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval fielda="A"
| eval char=mvfind(split("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",""), fielda)
| eval ascii=case(char&amp;lt;26,char+65,char&amp;lt;52,char+70,char&amp;lt;63,char-4,isnull(char),"??")
| eval hex=printf("%02x-%c", ascii, ascii)
| table fielda char ascii hex&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but that only handles letters and numbers and only standard ASCII charset - would not work for non english and other code pages.&lt;/P&gt;&lt;P&gt;You could create a case sensitive lookup, but these are all sledgehammers to crack a simple nut &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 01:18:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/546948#M155052</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-05-13T01:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/551409#M156484</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;wrote:&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;char=mvfind(split("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqwxyz0123456789",""), fielda)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great workaround.&amp;nbsp; Thanks a bunch.&amp;nbsp; Just a couple of quick edits for anyone else wanting to use this.&amp;nbsp; There's an extra q after the lower case v that needs to be removed.&lt;/P&gt;&lt;P&gt;Also. the 70 below should be 71.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;wrote:&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval ascii=case(char&amp;lt;26,char+65,char&amp;lt;53,char+70,char&amp;lt;63,char-5,isnull(char),"??")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 23:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/551409#M156484</guid>
      <dc:creator>user_bee</dc:creator>
      <dc:date>2021-05-12T23:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/566656#M197454</link>
      <description>&lt;P&gt;Two more corrections:&lt;/P&gt;&lt;P&gt;70-&amp;gt;71&lt;/P&gt;&lt;P&gt;63-&amp;gt;62&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval ascii=case(char&amp;lt;26,char+65,char&amp;lt;52,char+71,char&amp;lt;62,char-4,isnull(char),"??")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original (incorrect):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval ascii=case(char&amp;lt;26,char+65,char&amp;lt;52,char+70,char&amp;lt;63,char-4,isnull(char),"??")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 15:24:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/566656#M197454</guid>
      <dc:creator>user_bee</dc:creator>
      <dc:date>2021-09-10T15:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/566711#M197478</link>
      <description>&lt;P&gt;Decrypt2 should handle at least some of these scenarios...&amp;nbsp;&lt;A href="https://splunkbase.splunk.com/app/5565/" target="_blank"&gt;https://splunkbase.splunk.com/app/5565/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Sep 2021 09:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/566711#M197478</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2021-09-11T09:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Typecasting String to Hex/Dec/Oct</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/566720#M197482</link>
      <description>&lt;P&gt;That's why you can use larger base. In &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;'s example the base was 16 so no digit over "f" would be converted. But if you do tonumber("whatever",36), you'll be able to use whole a-z range.&lt;/P&gt;&lt;P&gt;In general - tonumber() is designed to convert a string representation of a number to a number. You just need to give it a proper base.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Sep 2021 16:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Typecasting-String-to-Hex-Dec-Oct/m-p/566720#M197482</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-11T16:13:06Z</dc:date>
    </item>
  </channel>
</rss>

