Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Downloads
Search: 

FoxCrypto
Albert Ballinger, Ballinger Consulting
FoxCrypto is a Visual FoxPro FLL library written by Albert Ballinger that wraps Wei Dai's public domain Crypto++ - a free C++ class library of cryptographic schemes. Only a subset of the Crypo++ functionality is exposed, the source is available and can be extended.
Created on
21 years ago
Downloads
1622
File type
Rating
5.00/5.00
General information
Rating:
5.00/5.00 (1 rate) Rate this item
Description
FoxCrypto is a Visual FoxPro FLL library written by Albert Ballinger that wraps Wei Dai's public domain Crypto++ - a free C++ class library of cryptographic schemes. FoxCrypto is exposes the following Cryto++ classes:
FoxCrypto Interface
Cryto++ ClassFoxCrypto Function
Base64Encoder
lcEncoded = Base64Encoder( tcBinary, tlInsertLineBreaks )
lnHandle = Base64EncoderCreate( tlInsertLineBreaks )
llSuccess = Base64EncoderDestroy( tnHandle )
lnSize = Base64EncoderPut( tnHandle, tcBinary )
llSuccess = Base64EncoderClose( tnHandle )
lnSize = Base64EncoderMaxRetrievable( tnHandle )
lcEncoded = Base64EncoderGet( tnHandle, tnSize )
Base64Decoder
lcBinary = Base64Decoder( tcEncoded )
lnHandle = Base64DecoderCreate()
llSuccess = Base64DecoderDestroy( tnHandle )
lnSize = Base64DecoderPut( tnHandle, tcEncoded )
llSuccess = Base64DecoderClose( tnHandle )
lnSize = Base64DecoderMaxRetrievable( tnHandle )
lcBinary = Base64DecoderGet( tnHandle, tnSize )
Gzip
lcGzipped = GzipEncoder( tcBinary, tnDeflateLevel )
lnHandle = GzipCreate( tnDeflateLevel )
llSuccess = GzipDestroy( tnHandle )
lnSize = GzipPut( tnHandle, tcBinary )
llSuccess = GzipClose( tnHandle )
lnSize = GzipMaxRetrievable( tnHandle )
lcGzipped = GzipGet( tnHandle, tnSize )
Gunzip
lcBinary = Gunzip( tcGzipped )
lnHandle = GunzipCreate()
llSuccess = GunzipDestroy( tnHandle )
lnSize = GunzipPut( tnHandle, tcGzipped )
llSuccess = GunzipClose( tnHandle )
lnSize = GunzipMaxRetrievable( tnHandle )
lcBinary = GunzipGet( tnHandle, tnSize )
HexEncoder
lcEncoded = HexEncoder( tcBinary, tlUpperCase )
lnHandle = HexEncoderCreate( tlUpperCase )
llSuccess = HexEncoderDestroy( tnHandle )
lnSize = HexEncoderPut( tnHandle, tcBinary )
llSuccess = HexEncoderClose( tnHandle )
lnSize = HexEncoderMaxRetrievable( tnHandle )
lcEncoded = HexEncoderGet( tnHandle, tnSize )
HexDecoder
lcBinary = HexDecoder( tcEncoded )
lnHandle = HexDecoderCreate()
llSuccess = HexDecoderDestroy( tnHandle )
lnSize = HexDecoderPut( tnHandle, tcEncoded )
llSuccess = HexDecoderClose( tnHandle )
lnSize = HexDecoderMaxRetrievable( tnHandle )
lcBinary = HexDecoderGet( tnHandle, tnSize )
ZlibCompressor
lcCompressed = ZlibCompressor( tcBinary, tnDeflateLevel )
lnHandle = ZlibCompressorCreate( tnDeflateLevel )
llSuccess = ZlibCompressorDestroy( tnHandle )
lnSize = ZlibCompressorPut( tnHandle, tcBinary )
llSuccess = ZlibCompressorClose( tnHandle )
lnSize = ZlibCompressorMaxRetrievable( tnHandle )
lcCompressed = ZlibCompressorGet( tnHandle, tnSize )
ZlibDecompressor
lcBinary = ZlibDecompressor( tcCompressed )
lnHandle = ZlibDecompressorCreate()
llSuccess = ZlibDecompressorDestroy( tnHandle )
lnSize = ZlibDecompressorPut( tnHandle, tcCompressed )
llSuccess = ZlibDecompressorClose( tnHandle )
lnSize = ZlibDecompressorMaxRetrievable( tnHandle )
lcBinary = ZlibDecompressorGet( tnHandle, tnSize )
CRC32
lcCode = CRC32( tcBinary )
lnHandle = CRC32Create()
llSuccess = CRC32Destroy( tnHandle )
lnSize = CRC32DigestSize()
lnSize = CRC32Update( tnHandle, tcBinary )
lcCode = CRC32Final( tnHandle )
MD5
lcCode = MD5( tcBinary )
lnHandle = MD5Create()
llSuccess = MD5Destroy( tnHandle )
lnSize = MD5DigestSize()
lnSize = MD5Update( tnHandle, tcBinary )
lcCode = MD5Final( tnHandle )
The latest version of FoxCrypto can be found at http://www.connectthenet.com/foxpro/FoxCrypto.fll. Some simple VFP test programs can be found at http://www.connectthenet.com/foxpro/FoxCryptoTest.zip. Please note that the Put and Get functions can be called iteratively. The FoxCrypto source code and Visual C++ 6.0 project can be found at http://www.connectthenet.com/foxpro/FoxCryptoSource.zip. The source should be unzipped to a FoxCrypto subdirectory under a directory containing the Crypto++ source. ----
* zlib_example
*
* Example of using the Zlib classes of FoxCrypto with
* a continuous status update.  This technique can be
* used with some sort of progress bar control.
*
* Zlib compression is guaranteed to return a string
* that is of equal or lesser length than the original.
* This makes Zlib compression a good candidate for
* compressing Memo field data.  Decompression follows
* analogous steps.

* This is the way to do this in one function call:
* SET LIBRARY TO FoxCrypto
* lcCompressed = ZlibCompressor( tcBinary, tnDeflateLevel )

#DEFINE BLOCK_SIZE	1024

DECLARE Sleep IN win32api AS Sleep INTEGER tnMilliseconds

SET LIBRARY TO FoxCrypto

LOCAL lnHandle, lcInString, lcOutString

lcInString = REPLICATE("Test String...", 10000)

LOCAL lnInStringLength, lnOutStringLength, lnProcessSize

lnInStringLength = LEN(lcInString)
lnProcessSize = 0

LOCAL i, lnHandle, lnSize

* create a ZlibCompressor object and store its handle
* 9 is the highest possible compression level, and the slowest
lnHandle = ZlibCompressorCreate(9)

IF lnHandle > 0
  FOR i = 1 TO lnInStringLength STEP BLOCK_SIZE
    * add a block of data to the compressor
    lnProcessSize = lnProcessSize + ;
      ZlibCompressorPut(lnHandle, SUBSTR(lcInString, i, BLOCK_SIZE))
    * give a status update
    SET MESSAGE TO "ZlibCompressor " + ;
      TRANSFORM(lnProcessSize) + ;
      " of " + ;
      TRANSFORM(lnInStringLength) + ;
      ", " + ;
      TRANSFORM(lnProcessSize / lnInStringLength * 100, "999.99") + "%"
    Sleep(200) && slow it down so we can see the messages
  ENDFOR
  * the compressor must be closed before the compressed string
  * is read back
  IF !ZlibCompressorClose(lnHandle)
    DO ReportError WITH ;
      "ZlibCompressor object close failed.", lnHandle
  ELSE
    * we will read back the whole string at once, we could
    * read it back in blocks
    lnSize = ZlibCompressorMaxRetrievable(lnHandle)
    IF lnSize < 1
      DO ReportError WITH ;
        "ZlibCompressor object has no compressed data to read.", lnHandle
    ELSE
      lcOutString = ZlibCompressorGet(lnHandle, lnSize)
      * destroy the compressor object
      IF !ZlibCompressorDestroy(lnHandle)
        DO ReportError WITH ;
          "ZlibCompressor object destruction failed."
      ELSE
        * give the final status
        SET MESSAGE TO "ZlibCompressor " + ;
          TRANSFORM(lnInStringLength) + ;
          " of " + ;
          TRANSFORM(LEN(lcOutString)) + ;
          ", " + ;
          TRANSFORM(LEN(lcOutString) / lnInStringLength * 100, ;
          "999.99") + "%"
      ENDIF
    ENDIF
  ENDIF
ELSE
  DO ReportError WITH ;
    "ZlibCompressor object creation failed."
ENDIF

PROCEDURE ReportError ( tcMessage, tnHandle )
  SET MESSAGE TO
  IF PCOUNT() > 1
    * try to clean up
    ZlibCompressorDestroy(tnHandle)
  ENDIF
  ERROR(tcMessage)
ENDPROC
Created by
Albert Ballinger, Ballinger Consulting

Comments