473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

one way password encryption

I am looking for the best way to one way encrypt a password for storage in a
database using (asp.net / vb.net)
basically I need some functions or examples that I can freely use in a
commercial project

anyone got any good functions or links I can look at ?

I was looking at MD5 hash .. the examples I saw confused me as I didn't see
a key ?
Does MD5 not used a key ?

I was also looking into SHA-1

I figure if I am going to do this I might as well make it a good as possible
within reason

any help or pointers is appretiated
Nov 21 '05 #1
4 5552
User supplies initial password
You create and store hash based on that password, you don't store the
original password and have no need to know what it actually was.

User tries to login and supplies password again.
You recreate hash using same function as before and compare hash to the one
you stored previously.

No key is required because you use the same hash function each time.

Keys are only necessary when you need to encrypt and then decrypt.

http://aspnet.4guysfromrolla.com/articles/112002-1.aspx has a good article
on password management with salt values.

"PJones" <pj****@hotmail .com> wrote in message
news:uP******** ******@TK2MSFTN GP09.phx.gbl...
I am looking for the best way to one way encrypt a password for storage in
a database using (asp.net / vb.net)
basically I need some functions or examples that I can freely use in a
commercial project

anyone got any good functions or links I can look at ?

I was looking at MD5 hash .. the examples I saw confused me as I didn't
see a key ?
Does MD5 not used a key ?

I was also looking into SHA-1

I figure if I am going to do this I might as well make it a good as
possible within reason

any help or pointers is appretiated

Nov 21 '05 #2
thanks Jim

seems like using the built in md5 stuff in .net along with some salt will be
good enough
maybe sha256 if I can find a good function for it


"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:uk******** ******@tk2msftn gp13.phx.gbl...
User supplies initial password
You create and store hash based on that password, you don't store the
original password and have no need to know what it actually was.

User tries to login and supplies password again.
You recreate hash using same function as before and compare hash to the
one you stored previously.

No key is required because you use the same hash function each time.

Keys are only necessary when you need to encrypt and then decrypt.

http://aspnet.4guysfromrolla.com/articles/112002-1.aspx has a good article
on password management with salt values.

"PJones" <pj****@hotmail .com> wrote in message
news:uP******** ******@TK2MSFTN GP09.phx.gbl...
I am looking for the best way to one way encrypt a password for storage in
a database using (asp.net / vb.net)
basically I need some functions or examples that I can freely use in a
commercial project

anyone got any good functions or links I can look at ?

I was looking at MD5 hash .. the examples I saw confused me as I didn't
see a key ?
Does MD5 not used a key ?

I was also looking into SHA-1

I figure if I am going to do this I might as well make it a good as
possible within reason

any help or pointers is appretiated


Nov 21 '05 #3
Well, let's get some terminolgy straight first, and that might help clear
things up :)

Encryption describes the act of applying a cipher to plain text, which
results in encrypted text (cipher text). You can then reverse the process to
get your original plain text.

A hash, on the other hand, has little to do with encryption directly
(meaning it's not an encryption cipher). A hash simply provides a calculated
value based on the input. Hashes have a number of properties:
1) The hash value is a given fixed size regardless of how much input you use
2) Using the same input will always result in the same hash value
3) It *should* be computationally infeasible to get the same hash value if
different input is used (this is not always guaranteed)
4) Hashes are one-way. You can't take a hash value and apply an algorithm to
retrieve the original input

Hashes are usually used as a message digest or message authentication code
to ensure content hasn't be tampered with (a hash before and after
transmission of data should provide the same results). However, for security
purposes as far as password storage goes, we run into a few snags.
First of all, since the same input always returns the same hash value, I can
take several hundred thousand words (and even some common funny spellings)
and create the hash value for all of them. I now have a dictionary. If i'm
able to get your hashed password list, I can compare them to my dictionary
and "lookup" the original text. This is one reason why strong passwords
(sequences of characters that are unlikely to be guessed in a dictionary
attack) are so important. But there are better ways to protect yourself.
There are indeed keyed hash algorithms, and the framework provides two of
them: HMACSHA1 and MACTripleDES. Because they require a key, a potential
attacker using a dictionary would have to create a dictionary for every
possible key value in a brute force dictionary attack. This ups the level of
security. The other thing you can do is salt is the input, as you've seen.
Finally, a big asset is to make sure you can prevent collisions (two input
values resulting in the same hash value). To do that, use the biggest hash
with the best algorithm. So far, I suspect that of all the non-keyed hashes
provided in the framework, SHA256 will be that algorithm. You don't have
"learn" how to use it, because all hash classes in the framework work the
same way. If you can use MD5, you can use SHA256. The only real difference
is that SHA256 will produce a longer hash value. Also note that, as you said
earlier, SHA and MD5 don't use keys.

-Rob
"PJones" <pj****@hotmail .com> wrote in message
news:uH******** ******@TK2MSFTN GP14.phx.gbl...
thanks Jim

seems like using the built in md5 stuff in .net along with some salt will be good enough
maybe sha256 if I can find a good function for it


"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:uk******** ******@tk2msftn gp13.phx.gbl...
User supplies initial password
You create and store hash based on that password, you don't store the
original password and have no need to know what it actually was.

User tries to login and supplies password again.
You recreate hash using same function as before and compare hash to the
one you stored previously.

No key is required because you use the same hash function each time.

Keys are only necessary when you need to encrypt and then decrypt.

http://aspnet.4guysfromrolla.com/articles/112002-1.aspx has a good article on password management with salt values.

"PJones" <pj****@hotmail .com> wrote in message
news:uP******** ******@TK2MSFTN GP09.phx.gbl...
I am looking for the best way to one way encrypt a password for storage ina database using (asp.net / vb.net)
basically I need some functions or examples that I can freely use in a
commercial project

anyone got any good functions or links I can look at ?

I was looking at MD5 hash .. the examples I saw confused me as I didn't see a key ?
Does MD5 not used a key ?

I was also looking into SHA-1

I figure if I am going to do this I might as well make it a good as
possible within reason

any help or pointers is appretiated



Nov 21 '05 #4
all very good info..

thank you rob for taking the time to explain in such detail

"Rob Teixeira" <RobTeixeira@@m sn.com> wrote in message
news:e6******** ******@TK2MSFTN GP15.phx.gbl...
Well, let's get some terminolgy straight first, and that might help clear
things up :)

Encryption describes the act of applying a cipher to plain text, which
results in encrypted text (cipher text). You can then reverse the process
to
get your original plain text.

A hash, on the other hand, has little to do with encryption directly
(meaning it's not an encryption cipher). A hash simply provides a
calculated
value based on the input. Hashes have a number of properties:
1) The hash value is a given fixed size regardless of how much input you
use
2) Using the same input will always result in the same hash value
3) It *should* be computationally infeasible to get the same hash value if
different input is used (this is not always guaranteed)
4) Hashes are one-way. You can't take a hash value and apply an algorithm
to
retrieve the original input

Hashes are usually used as a message digest or message authentication code
to ensure content hasn't be tampered with (a hash before and after
transmission of data should provide the same results). However, for
security
purposes as far as password storage goes, we run into a few snags.
First of all, since the same input always returns the same hash value, I
can
take several hundred thousand words (and even some common funny spellings)
and create the hash value for all of them. I now have a dictionary. If i'm
able to get your hashed password list, I can compare them to my dictionary
and "lookup" the original text. This is one reason why strong passwords
(sequences of characters that are unlikely to be guessed in a dictionary
attack) are so important. But there are better ways to protect yourself.
There are indeed keyed hash algorithms, and the framework provides two of
them: HMACSHA1 and MACTripleDES. Because they require a key, a potential
attacker using a dictionary would have to create a dictionary for every
possible key value in a brute force dictionary attack. This ups the level
of
security. The other thing you can do is salt is the input, as you've seen.
Finally, a big asset is to make sure you can prevent collisions (two input
values resulting in the same hash value). To do that, use the biggest hash
with the best algorithm. So far, I suspect that of all the non-keyed
hashes
provided in the framework, SHA256 will be that algorithm. You don't have
"learn" how to use it, because all hash classes in the framework work the
same way. If you can use MD5, you can use SHA256. The only real difference
is that SHA256 will produce a longer hash value. Also note that, as you
said
earlier, SHA and MD5 don't use keys.

-Rob
"PJones" <pj****@hotmail .com> wrote in message
news:uH******** ******@TK2MSFTN GP14.phx.gbl...
thanks Jim

seems like using the built in md5 stuff in .net along with some salt will

be
good enough
maybe sha256 if I can find a good function for it


"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:uk******** ******@tk2msftn gp13.phx.gbl...
> User supplies initial password
> You create and store hash based on that password, you don't store the
> original password and have no need to know what it actually was.
>
> User tries to login and supplies password again.
> You recreate hash using same function as before and compare hash to the
> one you stored previously.
>
> No key is required because you use the same hash function each time.
>
> Keys are only necessary when you need to encrypt and then decrypt.
>
> http://aspnet.4guysfromrolla.com/articles/112002-1.aspx has a good article > on password management with salt values.
>
> "PJones" <pj****@hotmail .com> wrote in message
> news:uP******** ******@TK2MSFTN GP09.phx.gbl...
>>I am looking for the best way to one way encrypt a password for storage in >>a database using (asp.net / vb.net)
>> basically I need some functions or examples that I can freely use in a
>> commercial project
>>
>> anyone got any good functions or links I can look at ?
>>
>> I was looking at MD5 hash .. the examples I saw confused me as I didn't >> see a key ?
>> Does MD5 not used a key ?
>>
>> I was also looking into SHA-1
>>
>> I figure if I am going to do this I might as well make it a good as
>> possible within reason
>>
>> any help or pointers is appretiated
>>
>
>



Nov 21 '05 #5

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

Similar topics

14
2934
by: Todd Johnson | last post by:
I am creating a dialog in wxPython for log in purposes. Basically when the user clicks the ok button, the dialog box saves the user name and password as class attributes. Then as long as the dialog exists calling MyDialog.GetUserName() and MyDialog.GetPassword() returns them. This seems insecure to me. Is there a better way to go about this or is it safe as long as I destroy the dialog as soon as I am done with it?
10
6011
by: Max | last post by:
Hello all, I am trying to protect a page within my site with a JS password scheme. Now I know JS can be quite easily "circumvented", but I came by a code below. My question is: 1. Is there a way to find a password for this script? How easily? 2. Is there a stronger scheme available in JS?
6
7521
by: Ian Davies | last post by:
Hello I would like to query the user table of the mysql database from my VB application to check that a user's password entered in a text field on a form corresponds to that users password in the mysql database. However, when I retreive the password using an sql statement into a recordset, it is encrypted. How can I decrypt it so I can make the comparison. Ian
5
1946
by: newbie | last post by:
Hello, I face a practical problem with encryption. I've read examples for encrypting a file with the DES algorythm. The algorythm uses a key and a IV value. Both are 8 bytes if I'm correct, and can be generated by the system or specified by me at design time. How can I then do DES encryption with a password? pwd: 8charact
11
15621
by: cooltoriz | last post by:
Hello there, I just found that the compiled code won't hide the string variables so that I can see them by opening the execuable using Notepad. I have couple applications that have password hardcoded and I've been thinking that the string varialbes are hidden in compiled code. I knew that the VS.NET doesn't compile the source code into machine code. But I didn't know that it will expose string variables in the compiled code. Here is my...
12
11088
by: =?Utf-8?B?am9uaWdy?= | last post by:
I wrote a simple VB.NET application that imports and edits CSV files. Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be opened separately. It is not high-sensitive data, I just don’t want folks to peek in the files. So time-consuming encryption is not necessary, just a simple password-to-open that I can program in my application so it internally opens the imported CSV file would be perfect, but I can’t...
2
2485
by: Jeff Williams | last post by:
I am developing an application which will allow users (students) to run applications on PC's with elevated rights. This is necessary for some applications which require Administrator rights on the PC. I now need to store the local administrator username and password somewhere where my application can read this from. I am looking for comments on 1. Recommend place to store this data
4
2791
by: Gilles Ganault | last post by:
Hello I'd like to encrypt a customer's organization name to use this as their password to launch our application, and decrypt it within our VB5 application. We will then use this information to print it on every page that the application prints out. That way, even if some other user gives out his password, it won't do any good, since the organization name will be the original user's.
0
2195
by: Jon.Hakkinen | last post by:
Hi all, I'm on DB2 9.5 fp 0 on Windows. I have a simple SQL stored procedure which uses the Encrypt() function to insert data in a table. I do not set the encryption password inside the procedure, I plan to issue an Set Encryption statement at the beginning of every database session from our middle layer. But for now I use clp or db2ce to run something like
0
8917
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9426
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...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
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
6022
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
4525
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...
1
3238
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
2163
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.