home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8vbsdk.exe / samples / multimedia / vbsamples / directplay / dxvbmessenger / modmsgshared.bas < prev   
Encoding:
BASIC Source File  |  2000-10-02  |  3.2 KB  |  82 lines

  1. Attribute VB_Name = "modMsgShared"
  2. Option Explicit
  3. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  4. '
  5. '  Copyright (C) 2000 Microsoft Corporation.  All Rights Reserved.
  6. '
  7. '  File:       modMsgShared.bas
  8. '
  9. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  10.  
  11. 'Constant encryption keys for both the server and client
  12. Public Const glClientSideEncryptionKey As Long = 169
  13. Public Const glServerSideEncryptionKey As Long = 131
  14.  
  15. 'Unique GUID for the app (used by DPlay)
  16. Public Const AppGuid = "{0AC3AAC4-5470-4cc0-ABBE-6EF0B614E52A}"
  17. 'Host and connect on this port
  18. Public Const glDefaultPort As Long = 9123
  19.  
  20. 'System Tray Declares/Constants/Types
  21. Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
  22. Public Type NOTIFYICONDATA
  23.     cbSize As Long
  24.     hwnd As Long
  25.     uID As Long
  26.     uFlags As Long
  27.     uCallbackMessage As Long
  28.     hIcon As Long
  29.     sTip As String * 64
  30. End Type
  31. Public Const NIM_ADD = &H0
  32. Public Const NIM_MODIFY = &H1
  33. Public Const NIM_DELETE = &H2
  34. Public Const NIF_MESSAGE = &H1
  35. Public Const NIF_ICON = &H2
  36. Public Const NIF_TIP = &H4
  37. Public Const NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
  38. Public Const WM_MOUSEMOVE = &H200
  39. Public Const WM_LBUTTONDBLCLK = &H203
  40. Public Const WM_RBUTTONUP = &H205
  41. Public sysIcon As NOTIFYICONDATA
  42.  
  43. Public Enum vbMessengerMsgTypes
  44.     'Login messages
  45.     Msg_Login 'Login information
  46.     Msg_LoginSuccess 'Logged in successfully
  47.     Msg_CreateNewAccount 'A new account needs to be created
  48.     Msg_InvalidPassword 'The password for this account is invalid
  49.     Msg_InvalidUser 'This user doesn't exist
  50.     Msg_UserAlreadyExists 'This user already exists (only can be received after a CreateNewAcct msg)
  51.     'Friend Controls
  52.     Msg_AddFriend 'Add a friend to my list
  53.     Msg_FriendAdded 'User was added
  54.     Msg_FriendDoesNotExist 'Tried to add a friend that doesn't exist
  55.     Msg_BlockUserDoesNotExist 'Tried to block a user that doesn't exist
  56.     Msg_BlockFriend 'Block someone from contacting me
  57.     Msg_FriendBlocked 'User was blocked
  58.     Msg_DeleteFriend 'Delete this user from my list of friends
  59.     Msg_SendClientFriends 'The Server will send the client it's list of friends
  60.     'Messages
  61.     Msg_SendMessage 'Send a message to someone
  62.     Msg_UserBlocked 'Can't send a message to this person, they've blocked you
  63.     Msg_ReceiveMessage 'Received a message
  64.     'Friend Logon messages
  65.     Msg_FriendLogon 'A friend has just logged on
  66.     Msg_FriendLogoff 'A friend has just logged off
  67. End Enum
  68.  
  69. 'Here we will use a very basic encrytion scheme.  We will encrypt the password
  70. 'on the client side, before we send it over to the server, and then decrypt it
  71. 'on the server side, and encrypt it once more before checking it against the database
  72. Public Function EncodePassword(sOldStr As String, ByVal lEncryptKey) As String
  73.  
  74.     Dim lCount As Long, sNew As String
  75.     
  76.     'Do a simple replace on each character in the string
  77.     For lCount = 1 To Len(sOldStr)
  78.         sNew = sNew & Chr$(Asc(Mid$(sOldStr, lCount, 1)) Xor lEncryptKey)
  79.     Next
  80.     EncodePassword = sNew
  81. End Function
  82.