Results 1 to 29 of 29

Thread: Add Powerful Encryption To Your Visual Basic Programs

Threaded View

  1. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Add Powerful Encryption To Your Visual Basic Programs

    Note: This doesn't run under Windows 2000 (with up to date service packs)

    I compiled the project, and it didn't run. It works fine under XP Home.

    Just found this, and it DOES work on both platforms. I don't know why.

    Code:
    Option Explicit 
    
    Dim sSecretData
    sSecretData = "Here is some very secret data." 
    
    ' Build up the key
    Dim wshNetwork, sComputerName
    Set wshNetwork = WScript.CreateObject("WScript.Network") 
    sComputerName = wshNetwork.ComputerName
    
    Dim capEData
    Set capEData = CreateObject("CAPICOM.EncryptedData")
    
    capEData.Algorithm = 3 'Use 3DES
    capEData.SetSecret sComputerName 
    capEData.Content = sSecretData
    
    Dim sCipherText
    sCipherText = capEData.Encrypt
    
    capEData.Algorithm = 3
    capEData.SetSecret sComputerName 
    capEData.Decrypt sCipherText
    
    Dim sPlainText
    sPlainText = capEData.Content 
    
    MsgBox "Original data: " & sSecretData & chr(13) _ 
      & "Encrypted data: " & sCipherText & chr(13) _ 
      & "Recoverd data: " & sPlainText
    Last edited by dglienna; Jan 7th, 2005 at 01:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width