473,770 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the original string from a HashCode byte[]?

gg
Hi, Dear All,
Please see the following code:

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHas h( Encoding.Unicod e.GetBytes( str) );
.....

I want to know how to get the original str -"1234" from m_str?

Thanks
Nov 16 '05 #1
3 8793
Hi, gg

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHas h( Encoding.Unicod e.GetBytes( str) );
....

I want to know how to get the original str -"1234" from m_str?


It is imposible to restore the data from the hash.

Your must store str valiable separate...

Look for sample at
http://msdn.microsoft.com/library/de...redentials.asp

Nov 16 '05 #2
"gg" <mx*****@hotmai l.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi, Dear All,
Please see the following code:

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHas h( Encoding.Unicod e.GetBytes( str) );
....

I want to know how to get the original str -"1234" from m_str?

Thanks

Can't be done. If you want the original string, don't use a hash function.
Use private key encryption.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Nov 16 '05 #3
gg <mx*****@hotmai l.com> wrote:
Please see the following code:

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHas h( Encoding.Unicod e.GetBytes( str) );
....

I want to know how to get the original str -"1234" from m_str?


Hashing is particularly designed to be a one-way process. If you want a
two-way process, look at the various symmetric or asymmetric
encryption/decryption algorithms in the System.Security .Cryptography
space.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6812
by: pentium77 | last post by:
Hi, Just wondering what's the algo used to compute hashcode in Java ? Does anybody here know ? Thanks, -MK.
4
4584
by: Burke Atilla | last post by:
While encrypting data with DES through CryptoStream makes encrypted data bigger than original string. if we have 8 byte key and 8 byte of data then the mode is ECB. output encrypted data is 16 bytes long. first 8 bytes is out encrypted key but last 8 byte unknown. and while decrypting if we couldn't supply this 8 bytes we couldnt decrypt data. and get exception "Bad Data" What is this 8 bytes and how can i supply this data if i have only the...
8
3545
by: MuZZy | last post by:
Hi, Why for god sake they change implementation of String.GetHashCode() from ..NET 1 to .NET 2? We were storing some user passwords in hashcode, now we can't upgrade those clients with .NET 2 vesrion of our app as they will not be able to log in. I know, we shouldn't have dealt with hashcode in the first place, but we
9
2092
by: archana | last post by:
Hi all, I have one question regarding hashing in .net I have two string containing same data. When i see hashcode by calling gethascode, i am getting same value. I want to know how internally strings are storing using hasing. Please clear my concept regarding hashing in ,net
1
7828
by: Alfredo Mesen | last post by:
I'm giving maintenance to someone elses sloppy code, on a servlet´s doPost it compares an input to determine the action that must be done, like if (action.equals("delete")) { ... } so was wondering if doing if (action.hashCode == new String("delete").hashCode())
6
2429
by: Mike9900 | last post by:
Hello, I am wondering why GetHashCode() for the string is using two differemt algorithms in .NET Framework 1.1 and 2. This is creating a big problem, because we relied on this hashcode as unique. How can we fix this problem? -- Mike
22
7695
by: j1mb0jay | last post by:
I have had to create a simple string encryption program for coursework, I have completed the task and now have to do a write up on how it could be improved at a later date. If you could look through the code and point me in the correct direction one would be very grateful. Example Input : j1mb0jay Example Output 1 : rZHKZbYZWn/4UgL9mAjN2DUz7X/UpcpRxXM9SO1QkvkOe5nOPEKnZldpsB7uHUNZ Example Output 2 :...
1
5499
by: nickyeng | last post by:
The following code i search some where from websites. it generate hash value for a string. but is that possible that convert it back to original string ? like if the string is "this is string" and hash value is "dje3h344h3hk4w9sjs" (just an example)... so how i'm going to make the hash value back to original string ? can anyone help ?
6
10044
by: j1mb0jay | last post by:
I am currently working on a dictionary populating program. I currently have a socket connection my local news server and am trawling through all of the articles looking for new words. I am currently using Java to do this but would like to move the source to C#. Java's String class has a method that hashes strings. I was wondering if C# has a method which does the same? In my Java version of the program I am using the Multiply Add and...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.