Hi,

Here are the VBScript functions to Encode and Decode the passwords. The
EncodePassword function expects a clear text password and username as
strings. The EncodePassword function returns a string with the password
encoded as hexadecimal digits. It is sutiable for writing to the registry.
The DecodePassword function expects an encoded password string (hexadecimal
digits) and a username. DecodePassword returns a clear text string that is
the password.

Mike


Function EncodePassword( Password, UserName )

Dim Encode
Dim EncodedStr
Dim EncodeVal
Dim PassLen
Dim i

  Encode = ""
  EncodedStr = ""
  EncodeVal = 0
  PassLen = Len(Password)

  If UserName <> "" Then
    If Len(UserName) = PassLen Then
      Encode = UserName
    ElseIf Len(UserName) > PassLen Then
      Encode = Left(UserName, PassLen)
    Else
      Do While Len(Encode) < PassLen
        Encode = Encode & UserName
      Loop
      If Len(Encode) > PassLen Then
        Encode = Left(Encode, PassLen)
      End If
    End If
    For i = 1 TO PassLen
      EncodeVal = Asc( Mid( Password, i, 1) )
      EncodeVal = EncodeVal + Asc( Mid( Encode, i, 1) )

      Select Case Int( EncodeVal / 16 )
        Case 0
          EncodedStr = EncodedStr & "0"
        Case 1
          EncodedStr = EncodedStr & "1"
        Case 2
          EncodedStr = EncodedStr & "2"
        Case 3
          EncodedStr = EncodedStr & "3"
        Case 4
          EncodedStr = EncodedStr & "4"
        Case 5
          EncodedStr = EncodedStr & "5"
        Case 6
          EncodedStr = EncodedStr & "6"
        Case 7
          EncodedStr = EncodedStr & "7"
        Case 8
          EncodedStr = EncodedStr & "8"
        Case 9
          EncodedStr = EncodedStr & "9"
        Case 10
          EncodedStr = EncodedStr & "A"
        Case 11
          EncodedStr = EncodedStr & "B"
        Case 12
          EncodedStr = EncodedStr & "C"
        Case 13
          EncodedStr = EncodedStr & "D"
        Case 14
          EncodedStr = EncodedStr & "E"
        Case 15
          EncodedStr = EncodedStr & "F"
      End Select

      Select Case Int( EncodeVal MOD 16 )
        Case 0
          EncodedStr = EncodedStr & "0"
        Case 1
          EncodedStr = EncodedStr & "1"
        Case 2
          EncodedStr = EncodedStr & "2"
        Case 3
          EncodedStr = EncodedStr & "3"
        Case 4
          EncodedStr = EncodedStr & "4"
        Case 5
          EncodedStr = EncodedStr & "5"
        Case 6
          EncodedStr = EncodedStr & "6"
        Case 7
          EncodedStr = EncodedStr & "7"
        Case 8
          EncodedStr = EncodedStr & "8"
        Case 9
          EncodedStr = EncodedStr & "9"
        Case 10
          EncodedStr = EncodedStr & "A"
        Case 11
          EncodedStr = EncodedStr & "B"
        Case 12
          EncodedStr = EncodedStr & "C"
        Case 13
          EncodedStr = EncodedStr & "D"
        Case 14
          EncodedStr = EncodedStr & "E"
        Case 15
          EncodedStr = EncodedStr & "F"
      End Select

    Next
    EncodePassword = EncodedStr
  Else
    EncodePassword = " "
  End If
End Function

Function DecodePassword( Password, UserName )

Dim Encode
Dim EncodedStr
Dim EncodeVal
Dim PassLen
Dim i
Dim Ix

  Encode = ""
  EncodedStr = ""
  EncodeVal = 0
  PassLen = Len(Password) / 2

  If UserName <> "" Then
    If Len(UserName) = PassLen Then
      Encode = UserName
    ElseIf Len(UserName) > PassLen Then
      Encode = Left(UserName, PassLen)
    Else
      Do While Len(Encode) < PassLen
        Encode = Encode & UserName
      Loop
      If Len(Encode) > PassLen Then
        Encode = Left(Encode, PassLen)
      End If
    End If

    Ix = 1
    For i = 1 TO PassLen
      Select Case Mid( Password, Ix, 1)
        Case "0"
          EncodeVal = 0
        Case "1"
          EncodeVal = 16
        Case "2"
          EncodeVal = 32
        Case "3"
          EncodeVal = 48
        Case "4"
          EncodeVal = 64
        Case "5"
          EncodeVal = 80
        Case "6"
          EncodeVal = 96
        Case "7"
          EncodeVal = 112
        Case "8"
          EncodeVal = 128
        Case "9"
          EncodeVal = 144
        Case "A"
          EncodeVal = 160
        Case "B"
          EncodeVal = 176
        Case "C"
          EncodeVal = 192
        Case "D"
          EncodeVal = 208
        Case "E"
          EncodeVal = 224
        Case "F"
          EncodeVal = 240
      End Select
      Ix = Ix + 1

      Select Case Mid( Password, Ix, 1)
        Case "0"
          EncodeVal = EncodeVal + 0
        Case "1"
          EncodeVal = EncodeVal + 1
        Case "2"
          EncodeVal = EncodeVal + 2
        Case "3"
          EncodeVal = EncodeVal + 3
        Case "4"
          EncodeVal = EncodeVal + 4
        Case "5"
          EncodeVal = EncodeVal + 5
        Case "6"
          EncodeVal = EncodeVal + 6
        Case "7"
          EncodeVal = EncodeVal + 7
        Case "8"
          EncodeVal = EncodeVal + 8
        Case "9"
          EncodeVal = EncodeVal + 9
        Case "A"
          EncodeVal = EncodeVal + 10
        Case "B"
          EncodeVal = EncodeVal + 11
        Case "C"
          EncodeVal = EncodeVal + 12
        Case "D"
          EncodeVal = EncodeVal + 13
        Case "E"
          EncodeVal = EncodeVal + 14
        Case "F"
          EncodeVal = EncodeVal + 15
      End Select
      Ix = Ix + 1

      EncodeVal = EncodeVal - Asc(Mid(Encode, i, 1))
      EncodedStr = EncodedStr & Chr(CLng(EncodeVal))
    Next
    DecodePassword = EncodedStr
  Else
    DecodePassword = ""
  End If
End Function

----- Original Message -----
From: "Imran Aziz" <[EMAIL PROTECTED]>
To: "Andy Paluch" <[EMAIL PROTECTED]>
Cc: "Imail Forums" <[EMAIL PROTECTED]>
Sent: Monday, April 09, 2001 7:32 PM
Subject: Re: [IMail Forum] Domain and User Creation through Code!


> Hello Andy,
>   Thanks a lot for the asptools , I will check them out ! I have been
successful in creating the domains by altering the registry entries , the
next thing to do is to create users in the domain , the only problem with
this is to encrypt the password for the new user ! I am trying to figure out
how to get it done !
>  If anyone knows about this please do let me know! I have mailed this
issue to imail support team and they have been very helpful till now.
> Imran.
> ---------- Original Message ----------------------------------
> From: "Andy Paluch" <[EMAIL PROTECTED]>
> Date: Mon, 9 Apr 2001 09:15:27 -0500
>
> >Maybe this can help. If nothing else may the author can shed some light.
> >
> >Andy
> >
> >----- Original Message -----
> >From: "Imran Aziz" <[EMAIL PROTECTED]>
> >To: "Andy Paluch" <[EMAIL PROTECTED]>
> >Sent: Monday, April 09, 2001 5:01 AM
> >Subject: Re: [IMail Forum] Domain and User Creation through Code!
> >
> >
> >> Hello Andy,
> >>    Thanks for the response , but the thing is that the ExtactUsers.zip
> >that I already have only extracts the users from the imail database , I
> >need a way to  encrypt password for the users so that I can alter the
> >registry entires to create new domain and users . I can make all the
> >rest of the entries for the new domain , but I need to know the
> >encryption method of user password for imail.
> >> Imran.
> >> ---------- Original Message ----------------------------------
> >> From: "Andy Paluch" <[EMAIL PROTECTED]>
> >> Date: Sat, 7 Apr 2001 23:21:25 -0500
> >>
> >> >Try this:
> >> >http://207.51.255.205/ExtractUsers.zip
> >> >
> >> >It will extract all users from the registry into text files, or
> >directly
> >> >into a database.  View the readme.txt file contained in the zip for
> >> >usage
> >> >instructions.
> >> >
> >> >----- Original Message -----
> >> >From: "Imran Aziz" <[EMAIL PROTECTED]>
> >> >To: "Imail Forums" <[EMAIL PROTECTED]>
> >> >Sent: Saturday, April 07, 2001 7:23 PM
> >> >Subject: [IMail Forum] Domain and User Creation through Code!
> >> >
> >> >
> >> >> Hello All,
> >> >>   Some time ago I created a com object that uses the adddomain.exe
> >and
> >> >adduser.exe of imail to create new domains and user , but it seems
> >that
> >> >because of being an external exe it is not only very slow but number
> >of
> >> >times misses users to be added the the domain . I sent a mail to
> >> >ipswitch support about the issue , and asked if there was some other
> >way
> >> >to get this done in programming . They suggested that I should alter
> >the
> >> >registry directly and created domain and users with that ! and should
> >> >post a message on imail forums as number of people on the forums have
> >> >done this already .
> >> >>   So Kindly if someone has done this can they guide me how they did
> >> >the Job , and secondly if I do alter the registry to create domains
> >and
> >> >users , I see that the imail user password is encrypted in some
> >format ,
> >> >how can I encrpt the password in my code so that the imail server may
> >> >recognize it .
> >> >> Any help in this respect would be most appreciated .
> >> >> Thanks a lot in advance.
> >> >> Regards,
> >> >> Imran.
> >> >> Software Engineer.
> >> >> Advanced Communications
> >> >> http://advcomm.net
> >> >>
> >> >>
> >> >> Please visit http://www.ipswitch.com/support/mailing-lists.html
> >> >> to be removed from this list.
> >> >>
> >> >> An Archive of this list is available at:
> >> >> http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
> >> >>
> >> >
> >> >
> >>
> >
> >
>
> Please visit http://www.ipswitch.com/support/mailing-lists.html
> to be removed from this list.
>
> An Archive of this list is available at:
> http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
>


Please visit http://www.ipswitch.com/support/mailing-lists.html 
to be removed from this list.

An Archive of this list is available at:
http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

Reply via email to