<?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: Randomizing text? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/536585#M174608</link>
    <description>&lt;P&gt;Another way of generating a random string would be to combine a few evals containing data and then concatenate random substrings of those evals. As an example, this will create a random 8 character alpha-numeric string with special characters.&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval&lt;BR /&gt;rand_lower="abcdefghijklmnopqrstuvwxyz"&lt;BR /&gt;,rand_upper=upper("abcdefghijklmnopqrstuvwxyz")&lt;BR /&gt;,rand_number=1234567890&lt;BR /&gt;,rand_special="!#$%*"&lt;BR /&gt;,len_lower=len(rand_lower)&lt;BR /&gt;,len_upper=len(rand_upper)&lt;BR /&gt;,len_number=len(rand_number)&lt;BR /&gt;,len_special=len(rand_special)&lt;BR /&gt;,RandomString=substr(rand_upper, (random() % len_upper), 1).substr(rand_lower, (random() % len_lower), 1).substr(rand_lower, (random() % len_lower), 1).substr(rand_special, (random() % len_special), 1).substr(rand_lower, (random() % len_lower), 1).substr(rand_number, (random() % len_number), 1).substr(rand_upper, (random() % len_upper), 1).substr(rand_lower, (random() % len_lower), 1)&lt;BR /&gt;| fields - rand_* len_*&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2021 22:19:21 GMT</pubDate>
    <dc:creator>894859</dc:creator>
    <dc:date>2021-01-20T22:19:21Z</dc:date>
    <item>
      <title>Randomizing text?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/348686#M174605</link>
      <description>&lt;P&gt;I'm looking to obscure data by randomizing text.  Does anyone have a simple way to do this against a field in Splunk?  Let's assume that I'm doing this to export the data sample.  I could eliminate the field altogether, but would like a randomized placeholder, vs just using eval of a fixed value or using random() which is numeric.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 21:29:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/348686#M174605</guid>
      <dc:creator>the_wolverine</dc:creator>
      <dc:date>2017-06-16T21:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Randomizing text?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/348687#M174606</link>
      <description>&lt;P&gt;Does it have to be random?&lt;/P&gt;

&lt;P&gt;Start with this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval fieldToObscure="This is organized text of length=35"
| eval len=len(fieldToObscure)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval base_string="12345678901234567890123456789012345678901234567890123456789012345678901234567890"
| eval fieldToObscure=substr(base_string, 0, len)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Non-random, but probably seems enough like it to work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval fieldToObscure=substr(md5(fieldToObscure), 0, len)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 21:40:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/348687#M174606</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-16T21:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Randomizing text?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/348688#M174607</link>
      <description>&lt;P&gt;How about this (go get 50 sample events randomly)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | streamstats count as sno | where sno%50=0 | table whateverfield
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 21:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/348688#M174607</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-16T21:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Randomizing text?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/536585#M174608</link>
      <description>&lt;P&gt;Another way of generating a random string would be to combine a few evals containing data and then concatenate random substrings of those evals. As an example, this will create a random 8 character alpha-numeric string with special characters.&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval&lt;BR /&gt;rand_lower="abcdefghijklmnopqrstuvwxyz"&lt;BR /&gt;,rand_upper=upper("abcdefghijklmnopqrstuvwxyz")&lt;BR /&gt;,rand_number=1234567890&lt;BR /&gt;,rand_special="!#$%*"&lt;BR /&gt;,len_lower=len(rand_lower)&lt;BR /&gt;,len_upper=len(rand_upper)&lt;BR /&gt;,len_number=len(rand_number)&lt;BR /&gt;,len_special=len(rand_special)&lt;BR /&gt;,RandomString=substr(rand_upper, (random() % len_upper), 1).substr(rand_lower, (random() % len_lower), 1).substr(rand_lower, (random() % len_lower), 1).substr(rand_special, (random() % len_special), 1).substr(rand_lower, (random() % len_lower), 1).substr(rand_number, (random() % len_number), 1).substr(rand_upper, (random() % len_upper), 1).substr(rand_lower, (random() % len_lower), 1)&lt;BR /&gt;| fields - rand_* len_*&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 22:19:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/536585#M174608</guid>
      <dc:creator>894859</dc:creator>
      <dc:date>2021-01-20T22:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Randomizing text?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/536596#M174610</link>
      <description>&lt;P&gt;Similar to&amp;nbsp;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406" target="_blank" rel="noopener"&gt;@woodcock&lt;/A&gt;'s answer, Splunk 8.1 adds the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/8.1.1/SearchReference/MultivalueEvalFunctions#mvmap.28X.2CY.29" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;mvmap&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function to iterate over multi-valued field values. This makes it easy to replace characters in a string:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults
| eval value="randomize this"
| eval mask=" !\"#$%&amp;amp;'()*+,-./0123456789:;&amp;lt;=&amp;gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
| eval random_value=mvjoin(mvmap(split(value, ""), substr(mask, random()%len(mask), 1)), "")&lt;/LI-CODE&gt;&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/8.1.1/SearchReference/TextFunctions#replace.28X.2CY.2CZ.29" target="_self" rel="nofollow noopener noreferrer"&gt;replace&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.1/SearchReference/Rex" target="_self" rel="nofollow noopener noreferrer"&gt;rex&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command can also be used to mask values, but the replacement value is only evaluated once:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults
| eval value="randomize this"
| eval masked_value=replace(value, ".", "*")&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults
| eval value="randomize this"
| rex field=value mode=sed "s/./*/g"&lt;/LI-CODE&gt;&lt;P&gt;Hash functions, lookup tables, and other methods are also useful, depending on why you want to randomize, mask, or deidentify your data.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 00:20:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Randomizing-text/m-p/536596#M174610</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-01-21T00:20:38Z</dc:date>
    </item>
  </channel>
</rss>

