Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
A client for testing non-blocking Winsock server
Form Magnifier
How to extract frames from AVI files
Listing INF files in a specified directory
Retrieving Network Provider information
Disabling drawing in the VFP form
Enumerating devices installed on the local machine
How to view icons stored in executable files (Icon Viewer)
Using GetFileSize
Windows Shell Icons displayed and exported to ICO files (Vista)
Accessing examples contained in this reference from a VFP application
Dial the Net Automatically
Drawing a rectangle using Windows regular edges and borders
Extended MessageBox Class
How to enable the SE_SHUTDOWN_NAME privilege for the application
Retrieving names for the registered clipboard formats
URL: splitting into its component parts
How to Start a Process as Another User (NT/XP/2K)
Storing registration key in the resources of an executable file
System Image List Viewer
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Validating the heap of the calling process
Winsock: reading and setting socket options
Accessing Windows Control Panel from VFP Application
A class that encrypts and decrypts files using Cryptography API Functions

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
The EncryptDecrypt class uses several Cryptography API Functions to implement password-protected encryption and decryption of files.


Do you think there are some similarities?


Here is an example of code that encrypts a file:
LOCAL oEnc As EncryptDecrypt
oEnc = CREATEOBJECT("EncryptDecrypt")

WITH oEnc
        IF NOT .GenerateKey("foxpro") && a password
                ? .errorno, .errormessage
        ELSE
                IF NOT .EncryptFile("c:\myfiles\somefile.txt",;
                        "c:\myfiles\somefile.enc")
                        ? .errorno, .errormessage
                ENDIF
        ENDIF
ENDWITH

The decryption is same simple:
WITH oEnc
        IF NOT .GenerateKey("foxpro") && use same password
                ? .errorno, .errormessage
        ELSE
                IF NOT .DecryptFile("c:\myfiles\somefile.enc",;
                        "c:\myfiles\somefile.enc.txt")
                        ? .errorno, .errormessage
                ENDIF
        ENDIF
ENDWITH

See also:
  • How to create MD-5 and SHA-1 hash values from a string
  • CryptoAPI: Collection of Providers class

  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    5981 bytes  
    Created: 2006-04-21 18:35:08  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 85  
    Listed functions:
    CryptAcquireContext
    CryptCreateHash
    CryptDecrypt
    CryptDeriveKey
    CryptDestroyHash
    CryptDestroyKey
    CryptEncrypt
    CryptHashData
    CryptReleaseContext
    GetLastError
    Printer friendly API declarations
    My comment:
    Default cryptographic service provider (CSP) is used along with algorithms CALG_MD5 for hashing and CALG_RC4 for encryption/decryption.

    Before encrypting or decrypting files, user must provide a password using the GenerateKey method of the class. A cryptographic session key is created from the hash of this password.

    A file is processed as a single block.

    * * *
    Oct.29, 2008: the EncryptBuffer method now allocates correct buffer size in cases when encrypted data is larger than the original plain text.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (184.72.184.104)
    3.5 hrs.Function: 'CeRegQueryValueEx'
     Example: 'Displaying bitmap using the AlphaBlend function'
     Example: 'How to assemble an array of strings and pass it to external function'
    15.71 hrs.Example: 'Retrieving information about the main VFP window'
    17.1 hrs.Function: 'RegCloseKey'
    Function group: 'Registry'
     
    Function group: 'Windows Sockets 2 (Winsock)'
    19.06 hrs.Example: 'Enumerating Processes -- Win9*'
    19.07 hrs.Function: 'RegQueryValueEx'
    Function group: 'Registry'
    22.71 hrs.Example: 'How to drag a Form not using its Titlebar or Caption'
     Example: 'How to generate UUID values'
    Google
    Advertise here!