Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
nteger ash (String inputString)
{
Integer outputNumber = 3;
Integer index=0;
Integer lengthOfInputString=inputString.Length;
Integer d =w
Integer ds =4
Integer fdsf =dsd

while(index<lengthofinputstring)
{
outputnumber=(outputnumber*3+letters.indexof(inputstring[index]));
index=index+1;
}
return outputnumber;
}


that="" produced="" the="" hashed="" output="" (integer="" value)="" as


provided,="" input="" string="" length="" was="" 9="" and="" contains="" only="" characters="" from="" below="" string

What I have tried:

<d;b=d""&gdt;dWhat I have tried:

Trgied to find out Please give me a solution.
Thanks in advance.
Posted
Updated 3-May-19 22:52pm
v18
Comments
Richard Deeming 7-Aug-18 13:56pm    
Changing the content of your question after other people have taken the time to help you is EXTREMELY rude.

I have rolled back your destructive edit.
Richard MacCutchan 4-May-19 4:02am    
No, you have already received explanations why not.
Richard MacCutchan 4-May-19 4:41am    
You have posted a question which has received some answers, so it needs to stay open to help other people facing similar issues. Any questions or answers posted here are in the public domain, which is the purpose of the site.
Richard MacCutchan 4-May-19 4:57am    
Please stop making all this fuss. If you do not like the rules here then feel free to go elsewhere.
Richard MacCutchan 4-May-19 9:23am    
Yes, you can do it from your account settings page.

You can't. That's not an encryption algorithm, it's a hashing algorithm (not a good one, but it works)
The difference is that an encryption algorithm can be reversed to produce the original input, which a hashing algorithm can't - they are used for different purposes.
For example, if you have two inputs 42 and 17 and your hashing algorithm is "add them together" then you get the hash value 59. But ... there are a huge range of numbers that will generate the same hash value: (58, 1), (57, 2), (56, 3) and you cannot tell from the output result which pair of numbers you started with (or even that it was only two numbers!

Your hash value can be reversed for very short strings, but as soon as the length goes up (or your input string contains a character not in your letters collection) it becomes impossible to reverse.

You can reverse it for short strings, by taking the modulus 37 and using that to index the letters collection, then dividing the hash by 37 ready for the next digit - but it shoudln't be trusted!
 
Share this answer
 
Comments
Maciej Los 9-May-18 3:41am    
5ed!
That's, like many hashing algorithms, it is not directly invertible. See Hash function - Wikipedia[^].
 
Share this answer
 
Comments
Maciej Los 9-May-18 3:41am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900