🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools
Article #929

Re: Password encryption/de-cryption

#929
From: Julio Canto
Date: Wed, 09 Aug 1995 09:27
51 lines
2450 bytes
In article <NEWTNews.807898837.21140.shah@shah.wg.com>, shah@wg.com wrote:
>Hi there !
Hail to you!

>I am developing a windows 3.1 app.  This app needs to authenticate a user 
>login by the user name and his/her password.  I need to store this password 
>in some sort of a format in some sort of a file (maybe an ini file).  But 
>first I need to encrypt this password and later on de-crypt to check against 
>the entered password (or maybe there is a better way - I just don't know 
>yet).  Could any of you please point me in a better way or point me to some 
>known used technique for this procedure ?
>I would much appreciate your help.
>Thanks

Here you are:

 FUNCTION ConvertTxt (S : String) : String;
 Var X : Byte;
 Begin
   ConvertTxt[0] := S[0];
   For X := 1 to Length(S) do
     ConvertTxt[X] := Chr(Ord(S[X]) XOR (Random(128) or 128));
 End;
 
 To encrypt a string, you just call ConvertTxt(string). Call
 the function again, with the same parameters to decrypt.
 Anyone have anything better, or have any suggestions?

 Here is basically the same function again.  However note the
 RandSeed assignment - RandSeed is set to the length of the
 string before a string is processed.  Since the length of
 the string never changes, you can randomly pick any string
 and be able to decrypt it.  RandSeed is used to make Random
 return a specific sequence of psuedo-random numbers, and
 this encryption method relies on the same sequence in order
 for it to decrypt.

  PROCEDURE EnDecrypt(VAR S: String);
  VAR
    X: Byte;
  BEGIN
    RandSeed := Length(S);
    FOR X := 1 TO Length(S) DO
      S[X] := Chr(Ord(S[X]) XOR (Random(128) OR 128));
  END;

Hope this helps.

Paz y pesetas.

.. "Ain't no time for regret when you body is in a bag" - BioHazard
Technical Details
Message-ID: <DD1EAJ.145@ta.es>
Path: arc1-ca.pugleaf.net!EU.net!goya!teice!Julio Canto
References: <NEWTNews.807898837.21140.shah@shah.wg.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.tools,comp.os.ms-windows.programmer.networks,comp.os.ms-windows.programmer.misc,comp.os.ms-windows.programmer.controls,comp.os.ms-windows.apps.utilities,comp.os.ms-windows.apps.misc,comp.os.ms-windows.apps.comm,comp.lang.c++
Path: arc1-ca.pugleaf.net!EU.net!goya!teice!Julio Canto
From: jcanto@vtools.es (Julio Canto)
Subject: Re: Password encryption/de-cryption
Message-ID: <DD1EAJ.145@ta.es>
Sender: usenet@ta.es (System Management news)
Organization: VTools SA
X-Newsreader: News Xpress Version 1.0 Beta #3
References: <NEWTNews.807898837.21140.shah@shah.wg.com>
Date: Wed, 9 Aug 1995 09:27:54 GMT