Splunk Search

How to convert SHA1 value to integer with base 16?

aps
New Member

Hi ,,

i am looking for the way if i could convert sha1 value to integer with base 16 to do the further arithmetic operations on it using eval. 

i tried :

..... |eval sha=sha1("xyz123")|eval dec_number=tonumber(sha,16)

but dec_number is returning nothing. Could anyone suggest something ?

Labels (1)
Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

A SHA1 value would be an integer too big to represent in 64 bits, which probably is why tonumber fails.

What problem are you trying to solve?

---
If this reply helps you, Karma would be appreciated.
0 Karma

aps
New Member

Hi @richgalloway 

i need to filter some events based on "string SHA1" > decimal[16] integer value's mode operations. 

Something like -    
(SHA_Value.to_interger(16) % 100

i was checking if i could achieve it by using "tonumber" function with eval for mode operation. if you could suggest some other method or trick would be appreciated. 

 

0 Karma

yuanliu
SplunkTrust
SplunkTrust

As @richgalloway indicates, the problem is the scale of SHA1 that SPL cannot handle.  I did some test, and uncovered extremely buggy behavior when an integer approaches and exceeds 10 trillion, or 10^13. (What are limitations of numeric calculation/representations?)  In comparison, SHA1 is 40 digits HEX.  Your best bet is an external command.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...