Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
Winsock: sending email messages (SMTP, port 25)
Enumerating data formats currently available on the clipboard
Custom FTP Class for Visual FoxPro application
Splash Screen for the VFP application
How to download a file from the FTP server using FtpGetFile
Custom HttpRequest class (WinHTTP)
How to activate Windows Calculator
Detecting changes in connections to removable drives (VFP9)
How to convert a bitmap file to monochrome format (1 bpp)
Using WM_COPYDATA for interprocess communication (VFP9)
How to put a vertical text scrolling on the form (a movie cast)
Establishing connection using the SQLDriverConnect
Displaying bitmap using the AlphaBlend function
Using Font and Text functions
Mapping and disconnecting network drives
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to make a VFP form fading out when released (GDI+ version)
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: 121  
    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 (54.242.188.217)
    2.3 hrs.Example: 'How to play AVI file on the _screen'
     Example: 'How to enable the SE_SHUTDOWN_NAME privilege for the application'
    5.23 hrs.Example: 'Reading Internet Query options'
    7.13 hrs.Function: 'GetIpNetTable'
    Function group: 'IP Helper'
    7.54 hrs.Example: 'Mapping and disconnecting network drives'
     Example: 'How to print FoxPro form'
    7.66 hrs.Example: 'Storing screen shot of a form to bitmap file'
     Function: 'GetModuleFileName'
    9.31 hrs.Example: 'Displaying standard progress dialog box when copying files'
    9.32 hrs.Example: 'Printing Image File, programmatically set print page orientation to landscape'
    Google
    Advertise here!