Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please give me a SHA1 Source code which will encrypt/decrypt a file.source code must be in C#3.5
Posted
Comments
Sandeep Mewara 8-Apr-11 3:31am    
No effort.

SHA will not "encrypt/decrypt a file".

It is not an encryption algorithm.

It is a Hashing algorithm.

If you generate a SHA from a file, you cannot get the file back from the SHA value. At all. Ever. Period.

Did you really think that a 5Mb file could be "encrypted" into 128 bits, and then "decrypted" back to 5Mb, all without any encryption key?

Look instead at using TripleDES or similar depending on your application.
 
Share this answer
 
Comments
Manfred Rudolf Bihy 8-Apr-11 3:07am    
Agreed! 5+
Kim Togo 8-Apr-11 7:40am    
Total correct :-), my 5
Sergey Alexandrovich Kryukov 9-Apr-11 0:02am    
Agreed. A 5.
--SA
You can't use SHA for encrytion because it's just for hashing.
Have a look at TDES or RSA. C# has CryptoProvider for both.
 
Share this answer
 
Comments
Manfred Rudolf Bihy 8-Apr-11 3:14am    
Correct! 5+
Michel [mjbohn] 9-Apr-11 2:10am    
thanks :)
Kim Togo 8-Apr-11 7:41am    
Correct :-)
Michel [mjbohn] 9-Apr-11 2:10am    
thanks :)
Sergey Alexandrovich Kryukov 9-Apr-11 0:02am    
This is also an excellent answer, especially it offers the best alternative. I voted "Excellent mark".
--SA
SHA1[^] is a hash algorithm and eventhough this can be used to create an encryption algorithm like SHACAL[^] for instance this is not what you asked in your question. This having been said I advise you to reformulate your question so that we can really help you. The question is as it stands plain wrong.

Regards,

-MRB
 
Share this answer
 
v2
Comments
Nuri Ismail 8-Apr-11 3:44am    
Good advise, my 5.
Sergey Alexandrovich Kryukov 9-Apr-11 0:01am    
This is the best Answer as it points to pseudo-code (even better than code to my taste), so I vote 5.
--SA

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