HighTechTalks DotNet Forums  

Simple Encryption & Decryption

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss Simple Encryption & Decryption in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Fred Nelson
 
Posts: n/a

Default Simple Encryption & Decryption - 11-13-2003 , 02:13 PM






Hi:

I'm developing a web application and I'm trying to find a simple way to
encrypt and decrypt a password field. A one-way encryption won't work since
I need to be able to e-mail users their password if they loose it.

I have searched MSDN and there are obviously many VERY complex encryption
services available - I don't need certificates or PKI, Kerberos, etc - just
something simple:

* for example:

scrambledpassword = simpleencrypt(inpassword)

unscrambledpassword = simpledecrtyp(scrambledpassword)

Any help would be GREATLY apprecaited!

Thanks,

Fred



Reply With Quote
  #2  
Old   
Peter van der Goes
 
Posts: n/a

Default Re: Simple Encryption & Decryption - 11-14-2003 , 08:09 AM







"Fred Nelson" <fred (AT) smartybird (DOT) com> wrote

Quote:
Hi:

I'm developing a web application and I'm trying to find a simple way to
encrypt and decrypt a password field. A one-way encryption won't work
since
I need to be able to e-mail users their password if they loose it.

I have searched MSDN and there are obviously many VERY complex encryption
services available - I don't need certificates or PKI, Kerberos, etc -
just
something simple:

* for example:

scrambledpassword = simpleencrypt(inpassword)

unscrambledpassword = simpledecrtyp(scrambledpassword)

Any help would be GREATLY apprecaited!

Thanks,

Fred


Have you looked at the CryptoStream class in the .NET framework? From a
cursory examination, it would (in Asymmetric mode) appear to do what you
want, albeit not quite as simply as your code example above.
If CryptoStream is over the top for you, you might consider developing your
own simple encryption algorithm. This would be enough to discourage curious
amateurs, but would do little to deter the "real" bad guys.

--
Peter - [MVP - .NET Academic]





Reply With Quote
  #3  
Old   
Chellam
 
Posts: n/a

Default Simple Encryption & Decryption - 11-23-2003 , 01:37 AM



Hi Fred,

When you do a bit Operation XOR function You will be
getting crypted text.
Here is a sample in VC.Hope it helps

Basic is PWd data + key -> encrypted pwd -->Crypt
encrypted pwd +key = clear pwd -->Decrypt

STDMETHODIMP CCryptography::CryptDecrypt(BSTR Datas, BSTR
Key, BSTR *retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())

int KEYLEN =0;
int DATALEN =0;
char *key=NULL;
char *data =NULL;

CComBSTR appenddata;

appenddata.Append(Key);
appenddata.Append(Key);

key = new char[wcslen(appenddata)];
::wcstombs(key,appenddata,wcslen(appenddata)+1);

data = new char[wcslen(Datas)];
::wcstombs(data,Datas,wcslen(Datas)+1);

KEYLEN = ::SysStringLen(Key);
KEYLEN = (KEYLEN *2);
DATALEN = ::SysStringLen(Datas);


int *B;
int *P;
long l =0;

B = new int[KEYLEN];
P = new int[DATALEN+1];

for(l=0;l<KEYLEN;l++)
{
B[l]= int(key[l]);

}

for(l=0;l<DATALEN;l++)
{
P[l]= int(data[l]);
if (P[l] >= 230)
P[l] = P[l] - 230;
}

int I;
for(I=0;I<DATALEN-1;I++)
{
int T;
T = P[i]^B[i];
if((T^B[i]) == P[i])
P[i] = T;
}
CComBSTR Crypt;
for(I=0;I<DATALEN;I++)
{
if( P[i] <= 21)
P[i] = P[i] + 230;
char str[1];
str[0]=char(P[i]);
str[1]=NULL;
Crypt.Append(str);
}
*retval = Crypt.Copy();
return S_OK;
}

Thanks
Chellam


Quote:
-----Original Message-----
Hi:

I'm developing a web application and I'm trying to find a
simple way to
encrypt and decrypt a password field. A one-way
encryption won't work since
I need to be able to e-mail users their password if they
loose it.

I have searched MSDN and there are obviously many VERY
complex encryption
services available - I don't need certificates or PKI,
Kerberos, etc - just
something simple:

* for example:

scrambledpassword = simpleencrypt(inpassword)

unscrambledpassword = simpledecrtyp(scrambledpassword)

Any help would be GREATLY apprecaited!

Thanks,

Fred


.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.