A function that encrypts/decrypts.

By | 2002-06-01

2 functions 1 that encrypts a passed variable(string) and the other decrypts the data(path of file)
Mainly used for a single password.
The code encrypts each character with a simple formula, the more characters the better the encryption.
The limit on the password length is 50 characters.

Original Author: m@llot

Inputs

The encrypt function input is the passed variable which is the password to encrypt.

Assumptions

Its very simple, and not even close to “great” encryption. but it gets the job done for what it does.

Returns

The decrypt function returns the decrypted value

Side Effects

No side effects

Code

'simple just pass the password to it like this
'Encrypt("password")
Private Function Encrypt(varPass As String)
If Dir(path to save password to) <> "" Then: Kill "path to save password to"
Dim varEncrypt As String * 50
Dim varTmp As Double
Open "path to save password to" For Random As #1 Len = 50
  For I = 1 To Len(varPass)
  
   varTmp = Asc(Mid$(varPass, I, 1))
   varEncrypt = Str$(((((varTmp * 1.5) / 2.1113) * 1.111119) * I))
   Put #1, I, varEncrypt
  
  
  Next I
Close #1
End Function
'returns the decrypted pass
'like if decrypt() = "password" then
Private Function Decrypt()
Open "path to save password to" For Random As #1 Len = 50
  Dim varReturn As String * 50
  Dim varConvert As Double
  Dim varFinalPass As String
  Dim varKey As Integer
  
  
  For I = 1 To LOF(1) / 50
  
  
   Get #1, I, varReturn
   varConvert = Val(Trim(varReturn))
   varConvert = ((((varConvert / 1.5) * 2.1113) / 1.111119) / I)
   varFinalPass = varFinalPass & Chr(varConvert)
  
  
  Next I
  Decrypt = varFinalPass
Close #1
End Function

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.