473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How encrypt and decrypt password ?

hi,everyone i m creating a login page and i want to encrypt the password before insert that in to database and decrypt it before verification can enybody tell how to do this ?
Feb 10 '07 #1
6 2237
hariharanmca
1,977 1GB
hi,everyone i m creating a login page and i want to encrypt the password before insert that in to database and decrypt it before verification can enybody tell how to do this ?
you should be aware of string manipulation and you can use some formula which will convert the actual string and which will getback to actual string..
Feb 10 '07 #2
you should be aware of string manipulation and you can use some formula which will convert the actual string and which will getback to actual string..


thanx but i m not satisfied....ok bye the way can u tell me how to write algorithm for it ? or if any site from from where i can download or seen that algorithm...ok plz reply soon
Feb 10 '07 #3
Another alternative which I sometimes use is to encrypt the password into some other form, which you then store in the database, and then you check that the entered password encrypts to the same value for verification purposes.

This means the encryption doesn't need to be 'reversible' - you never need to get the password back from the stored value, so it's no use to anyone even if they steal the data, and you can encrypt the entered password before sending that for storing or verification, so you never send plain text passwords outside your application.

If you don't need to be particularly secure, here's a bit of PHP that you could easily convert to C or VB that turns a text password into a lightly-encrypted 'long integer'.

Store the result of the function as your password in the database. Then when you want to check a password, just hash the entered text and see if the result matches what was stored. That way you never store the actual password, and it is very difficult to turn the stored value back into anything usable.

Expand|Select|Wrap|Line Numbers
  1. function hash($key) {
  2.   $h = 0;
  3.  
  4.   for ($n = 0 ; $n < strlen($key) ; $n++) {
  5.     $h = (($h & 0x3FAFCF) * 131) + ord($key{$n});
  6.   }
  7.   return $h;
  8. }
  9.  
Regards,
Steve
Feb 10 '07 #4
hariharanmca
1,977 1GB
thanx but i m not satisfied....ok bye the way can u tell me how to write algorithm for it ? or if any site from from where i can download or seen that algorithm...ok plz reply soon
http://www.codeproject.com/useritems/Encrypt_an_string.asp

and there are more search in gogle.

you should undersatnd the algoritham then use it


Good luck...
Feb 10 '07 #5
Another alternative which I sometimes use is to encrypt the password into some other form, which you then store in the database, and then you check that the entered password encrypts to the same value for verification purposes.

This means the encryption doesn't need to be 'reversible' - you never need to get the password back from the stored value, so it's no use to anyone even if they steal the data, and you can encrypt the entered password before sending that for storing or verification, so you never send plain text passwords outside your application.

If you don't need to be particularly secure, here's a bit of PHP that you could easily convert to C or VB that turns a text password into a lightly-encrypted 'long integer'.

Store the result of the function as your password in the database. Then when you want to check a password, just hash the entered text and see if the result matches what was stored. That way you never store the actual password, and it is very difficult to turn the stored value back into anything usable.

Expand|Select|Wrap|Line Numbers
  1. function hash($key) {
  2.   $h = 0;
  3.  
  4.   for ($n = 0 ; $n < strlen($key) ; $n++) {
  5.     $h = (($h & 0x3FAFCF) * 131) + ord($key{$n});
  6.   }
  7.   return $h;
  8. }
  9.  
Regards,
Steve

Expand|Select|Wrap|Line Numbers
  1. Thank you so much will meet with new questions bye ?
  2.  
Feb 10 '07 #6
.NET has built in functions to do encryption and hashes

Here is a piece of code i use to create a MD5 Hash

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5. using System.Web;
  6.  
  7. public class Security
  8. {
  9.     //*********************************************************************
  10.     //
  11.     // Security.Encrypt() Method
  12.     //
  13.     // The Encrypt method encrypts a clean string into a hashed string
  14.     //
  15.     //*********************************************************************
  16.     public static string Encrypt(string cleanString)
  17.     {
  18.         Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString);
  19.         Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
  20.  
  21.         return BitConverter.ToString(hashedBytes);
  22.     }
  23.  
  24. }
Feb 10 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: wqhdebian | last post by:
As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does...
11
by: underwmd | last post by:
Hello, My problem is two fold. 1) I must support a deployed legacy application written in VB6 SP5. I need to export data from a database, compress it and the encrypt the data using 3DES (to...
2
by: Anilza Popat | last post by:
I would like to know how to encrypt and decrypt files using c#. I want a program that asks for password before encrypt or decrypt the file. best regards
8
by: Gidi | last post by:
Hi, Is there Buid-In fuction in C# that Encrypt and Decrypt strings? i have a textbox which i'm writing into file, and i want to encrypt it before writing, i'm not looking for something fancy,...
3
by: Alex Nitulescu | last post by:
Hi. I am writing an app which stores usernames/passwords and email addresses in a database table. The question is how can I encrypt the password provided by the user ? ...
7
by: Jean Christophe Avard | last post by:
Hi! I am designing an application wich comes with image file. These images are copyrighted and they have to be accessible only from within the application. At first, I tought I was going to store...
2
by: rino100 | last post by:
can anyone tell me why this c++ code works encrypting simple filenames but instead if you try to encrypt a filename like "video - 833 12_ ..avi" it doesn't rename the file?????? #include...
4
by: google | last post by:
OK, I know how to encrypt and decrypt data, but here's the deal: I have a large Winforms .NET 2.0 application which is currently storing the connection string in the app.config file unencrypted...
6
by: Aneesh P | last post by:
Hi All, I need to encrypt some fields esp password key values in configuration file while installting the application using .Net installer project and decrypt those values from my...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.