General discussion

Locked

The SPS Weblog

By craig ·
Tags: Off Topic
blog root

This conversation is currently closed to new comments.

94 total posts (Page 4 of 10)   Prev   02 | 03 | 04 | 05 | 06   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Visual FoxPro Scrollbar Classes

by craig In reply to The SPS Weblog

<p>
<strong>New Found Respect for Scrollbar Creation</strong>
<br>
Earlier this evening I decided to create a scrollbar class for use with Visual
FoxPro. My requirements were that it was created purely with Visual FoxPro (didn't
have any ActiveX dependecies) and that it was professional enough for use in
a real world Visual FoxPro application. It is now five hours later... the
class is complete and I have a new found respect for anyone who successfully creates
scrollbars. This turned out to be one of the more difficult challenges I have given
myself.
</p>
<p>
<strong>New VFPScrollBar Class Library<br>
</strong>I created my scrollbar classes in a class library called vfpscrollbar.vcx.
The three classes that are of note are the scrollbarhorizontal, scrollbarvertical,
and the sbscrollablecontainer. The sbscrollablecontainer is an example of the types
of classes that can be built using the scrollbars.
</p>
<p>
<strong>Properties and Events<br>
</strong>The following is a list of notable properties and methods for the scrollbars:<br>
<strong>Min</strong> - Specifies the minimum value for the scrollbar (defaults to
0)<br>
<strong>Max</strong> - Specifies the maximum value for the scrollbar (defaults to
500)<br>
<strong>Value</strong> - The current value of the scrollbar based on the position
of the thumb/scroll box<br>
<strong>LargeChange</strong> - The amount that is added or deducted from the scrollbar's
value when the area between the thumb/scroll box and the scroll arrows is clicked<br>
<strong>SmallChange</strong> - The amount that is added or deducted from the scrollbar's
value when the scroll arrows are clicked<br>
<strong>Change()</strong> - This event/method is fired whenever the value of the scrollbar
changes<br>
<strong>Scroll() -</strong> This event/method is fired whenever the user is moving
the thumb/scroll box<br>
<br>
When placing the scrollbar classes in a container (form or whatever), you can resize
the scrollbar making it wider and/or longer. The result at design time may look a
little odd (since the scroll arrows and thumb/scroll box don't resize or reposition
themselves at design time, but everything will shape up at runtime. The point is,
that you needn't spend a bunch of time making the scrollbars look good at design time.
Just place them, resize and position the main container and run it.<br>
<br>
<strong>Future Work and Colors<br>
</strong>Currently the scrollbars are blue (to match Windows XP theme), but I have
my eye towards eventually allowing the scrollbar classes color to be changed either
with a single property setting or by checking the user's current system settings and
pulling the color from there. I painstakingly created these scrollbar classes without
using any image so that the colors could be easily changed on the fly without additional
image resources.<br>
<br>
I'll also be revisiting the code and refactoring portions of it. As it is now, I am
burnt out on it (it was a rough five hours to get this thing to work and look right).
So, don't expect a code clinic with this class... I mean it's not horrible, but I
do need to take another pass through it before I will be happy with it.<br>
<br>
<strong>Suggestions and Bug Reports Welcome<br>
</strong>I also want to mention that a few members of the Visual FoxPro Community
have started to provide me with feedback, bug fixes and enhancements for the stuff
I am posting here on the SPS Weblog. I want you all to know that collaboration, help,
feedback, and/or ideas are not only welcomed and appreciated, but are exactly the
reason why I post these entries. I don't want fame or your money... I just want
to see the Visual FoxPro Community improve the state of Visual FoxPro and the overall
experience for developers that are working in it or companies that may be considering
it as a viable option. It is my belief that one of the greatest data-centric development
tools ever created deserves nothing less.<br>
<br>
Here is the download link for the example project and vfpscrollbar.vcx source as well
as a screen shot of the example that shows the scrollbars being used in the scrollable
container class.<br>
<br>
<a href="http://www.sweetpotatosoftware.com/files/vfpscrollbar.zip">Download VFP Scrollbars
Example and Source</a> (46 KB approx.)
</p>
<img src="http://www.sweetpotatosoftware.com/SPSBlog/content/binary/vfpscrollbar.gif" border=0>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,df3cb71d-588f-4bc6-b63e-9c94017edd7f.aspx">This post originally appeared on an external website</a></div>

Collapse -

Visual FoxPro and Blowfish Encryption

by craig In reply to The SPS Weblog

<p>
As security concerns mount, developers and clients are looking at ways to encrypt/decrypt
sensitive data and files. Visual FoxPro comes with a Crypto API example in the Solution
Samples, but more than a few Visual FoxPro developers have been bitten when using
this in distributed applications. I felt there were too many gotchas and, after running
into my fair share of client systems that it didn't work on, I eventually gave up
on it.>
</p>
<p>
<font color=#000000>What I wanted was something extremely secure and reliable
that was also very simple to use. So, I sat down and wrote an FLL that gives
Visual FoxPro developers access to the Blowfish cipher (this is not a mini version
of Blowfish, this is fullblown 16-Round based on work by <a href="http://www.schneier.com/">Bruce
Schneier</a> & Jim Conge). Some good information is available at the links below for
those of you that might not be familiar with Blowfish...</font>
</p>
<u><font face=Tahoma size=2><u><font face=Tahoma size=2>
<p>
<a href="http://en.wikipedia.org/wiki/Blowfish_(cipher">http://en.wikipedia.org/wiki/Blowfish_(cipher)</a>
</p>
<p>
<a href="http://www.schneier.com/paper-blowfish-oneyear.html">http://www.schneier.com/paper-blowfish-oneyear.html</a>
</p>
<p>
</u></font></u>font color=#000000>16-round Blowfish is very secure, extremely fast when
handling large amounts of data, and I like the idea of only having to write a
few lines of code to get reliable encryption and decryption for my Visual FoxPro
applications.</font>>
<p>
<font color=#000000><font face="Courier New">   SET LIBRARY TO LOCFILE("vfpencryption.fll")<br>
   cEncryptedString = BFEncrypt("Credit Card #35823908523105009", "My_SeCuRe_PaSsWoRd_kEY")<br>
   ? "Encrypted As: " + cEncryptedString<br>
   cDecryptedString = BFDecrypt(cEncryptedString, "My_SeCuRe_PaSsWoRd_kEY")<br>
   ? "Decrypted As: " + cDecryptedString</font>
<br>
</font>
<br>
<font color=#000000>Files can also be encrypted, simply use STRTOFILE() and FILETOSTR()
in conjunction with the above functions. I'll be adding native file encryption/decryption
and more encryption algorithms to this FLL in the coming months. The eventual goal
is to provide a number of security enhancements for Visual FoxPro, this FLL is just
the humble beginning of a much bigger plan. Here's the download link where you
can get the vfpencryption.fll and try out the example code above.</font>
</p>
<p>
<font color=#000000><a href="http://www.sweetpotatosoftware.com/files/vfpencryption.zip">Download
the vfpencryption.fll</a></font><font color=#000000> (9 KB approx.)<br>
</p>
>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,23a74c5d-5173-420e-af23-22494d95a54c.aspx">This post originally appeared on an external website</a></div>

Collapse -

Visual FoxPro and AES Encryption

by craig In reply to The SPS Weblog

<p>
<strong>Advanced Encryption Standard (AES) For Visual FoxPro<br>
</strong>If you read <a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,23a74c5d-5173-420e-af23-22494d95a54c.aspx">my
last blog entry</a>, then you know I'm working on putting together a comprehensive
set of encryption/decryption functions for Visual FoxPro via an FLL. Building on that,
I decided the next cipher I would implement was AES (a.k.a. Rijndael). The Visual
C++ code is based on earlier work by Szymon Stefanek, Vincent Rijmen, and K.U.Leuven
that is in the public domain. The AES encryption standard is good enough that it is
approved by the US government (among others) for encrypting Classified and Top Secret
information. This is arguably one of the best ciphers currently being used, and I
wouldn't be surprised if some of you readying this have had AES be a security requirement
on some of your projects. For additional information regarding AES you can see the
following link:
</p>
<p>
<a href="http://en.wikipedia.org/wiki/AES">http://en.wikipedia.org/wiki/AES</a>
</p>
<p>
<strong>Description of the new Visual FoxPro AES Encryption Functions<br>
<br>
</strong><u>Function Signatures<br>
</u><strong><font color=#006400>AesEncrypt</font></strong>(cString, cKey, [nMode,
[nKeySize]])<br>
<strong><font color=#006400>AesDecrypt</font></strong>(cString, cKey, [nMode, [nKeySize]])<br>
<br>
<u>Parameters<br>
</u><strong><font color=#006400>cString</font></strong>: String to encrypt/decrypt<br>
<strong><font color=#006400>cKey</font></strong>: Encryption Key to use (16, 24, or
32 characters depending on nKeySize)<strong><font color=#ff0000>*</font></strong>
<br>
<strong><font color=#006400>nMode</font></strong>: AES Mode (1 = ECB 2 = CBC)<br>
<strong><font color=#006400>nKeySize</font></strong>: Size of Key in bits (128, 192,
256)<br>
<br>
<font size=1><strong><font color=#ff0000>*</font></strong> The cKey parameter will
accept keys that aren't the right size and either pad or truncate them in order to
provide the internal FLL function with the correct key length, however this weakens
the overall security of the AES encryption and is strongly discouraged.</font>
</p>
<p>
<strong>Download the FLL and Start Using AES in Visual FoxPro<br>
</strong>Here is the download link and some cut-paste-and-execute sample code
so you can try it out. NOTE: I will be overwriting prior versions of the fll so the
links always point to the latest version. Also, should you want to see a specific
cipher or hash implemented in this FLL, or if you have some other suggestions/ideas,
please feel free to leave me a comment about it and I will see what I can do.
</p>
<p>
<a href="http://www.sweetpotatosoftware.com/files/vfpencryption.zip">Download the
VFP Encryption FLL</a> (22 KB approx.)
</p>
<p>
<strong>Example of Use<br>
<br>
</strong><font face="Courier New" size=1>CLEAR<br>
SET LIBRARY TO LOCFILE("vfpencryption.fll")<br>
#DEFINE ASECRET256BITKEY "LVE*(zz}}'rr)`P%wDq@lc8WWbGw0[77" && Example only,
make your own 32 character key<br>
? "__________________________"<br>
? "EXAMPLE #1 (simplest): USES DEFAULT AES - CBC MODE 256-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET256BITKEY)<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET256BITKEY)<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
? "__________________________"<br>
? "EXAMPLE #2: USES AES - ECB MODE 256-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET256BITKEY, 1, 256)<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET256BITKEY, 1, 256)<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
? "__________________________"<br>
? "EXAMPLE #3: USES AES - CBC MODE 256-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET256BITKEY, 2, 256)<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET256BITKEY, 2, 256)<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
? "__________________________"<br>
#DEFINE ASECRET192BITKEY "!rPrrj<t!fr7$7L?1#\\;lAV" && Example only, make
your own 24 character key<br>
? "EXAMPLE #4: USES AES - ECB MODE 192-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET192BITKEY, 1, 192)<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET192BITKEY, 1, 192)<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
? "__________________________"<br>
? "EXAMPLE #5: USES AES - CBC MODE 192-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET192BITKEY, 2, 192)<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET192BITKEY, 2, 192)<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
? "__________________________"<br>
#DEFINE ASECRET128BITKEY "!rPrrj<t!fr7$7L?1#\\;lAV" && Example only, make
your own 16 character key<br>
? "EXAMPLE #6: USES AES - ECB MODE 128-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET128BITKEY, 1, 12<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET128BITKEY, 1, 12<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
? "__________________________"<br>
? "EXAMPLE #7: USES AES - CBC MODE 128-BIT KEY"<br>
cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET128BITKEY, 2, 12<br>
cDecryptedString = AesDecrypt(cEncryptedString, ASECRET128BITKEY, 2, 12<br>
? "Encrypted: " + cEncryptedString<br>
? "Decrypted: " + cDecryptedString<br>
</font>
</p>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,5f4231f7-abc5-4649-a74d-6779f0bce659.aspx">This post originally appeared on an external website</a></div>

Collapse -

Visual FoxPro and Hash Functions

by craig In reply to The SPS Weblog

<p>
<strong>Hashing in Visual FoxPro<br>
</strong>There are a few popular hash functions that I thought made good candidates
for the VFP Encryption FLL. So, by modifying and adding to some earlier Visual C++
work by <a href="http://www.codeproject.com/cpp/filedigest.asp">George Anescu</a> I
implemented the following hashing functions: SHA1, SHA256, SHA384, SHA512, MD5, RIPEMD128,
and RIPEMD160. They are now all accessible from in Visual FoxPro using a very
simple Hash() function.
</p>
<p>
<strong>Bigger but still relatively small<br>
</strong>The hash functions added some size to the FLL that now weighs in at about
(108 KB), but I think with everything this FLL offers in the way of encryption and
hashing that it is still a pretty respectable size.
</p>
<p>
<strong>Additional information on the implemented hash functions<br>
</strong>For additional information on the hash functions now accessible to Visual
FoxPro refer to the following links:
</p>
<p>
<a href="http://en.wikipedia.org/wiki/SHA_hash_functions">http://en.wikipedia.org/wiki/SHA_hash_functions</a>
<br>
<a href="http://en.wikipedia.org/wiki/MD5">http://en.wikipedia.org/wiki/MD5</a>
<br>
<a href="http://en.wikipedia.org/wiki/RIPEMD-160">http://en.wikipedia.org/wiki/RIPEMD-160</a>
</p>
<p>
<strong>ReadMe.txt<br>
</strong>I've included a ReadMe.txt with the download that shows all of the different
functions now available in the vfpencryption.fll. I thought this might be a good thing
to have with the FLL should someone stumble acrossed it in the future and not know
about this blog. Also, it gives me a place to stick George Anescue's disclaimer (he's
certainly entitled as the work he's done is great and I appreciate him allowing other
developers such as myself to use and modify it freely). Here is some information from
the ReadMe.txt about the Hash() function:<br>
<br>
Function Signature<br>
Hash(cStringtoHash[, nHashType])
</p>
<p>
Parameters<br>
cString: String to return hash for<br>
nHashType: (possible values and corresponding hash)<br>
1 = SHA1 (a.k.a SHA160)  - 160 bit Digest<br>
2 = SHA256    - 256 bit Digest<br>
3 = SHA384    - 384 bit Digest<br>
4 = SHA512 (default hash type)  - 512 bit Digest<br>
5 = MD5    - 128 bit Digest<br>
6 = RIPEMD128    - 128 bit Digest<br>
7 = RIPEMD256    - 256 bit Digest
</p>
<p>
Though not always true, it can be generally said of these hash algorithms that the
longer the Digest is the more secure the hash is. It would be extremely difficult
to find a collision for a string hashed with SHA512, which is the default for this
Visual FoxPro Hash() function. A collision, simply put, is when you find another string
that would produce the same hash.
</p>
<p>
In order to represent hashes in the most common form of hexBinary use Visual FoxPro's
STRCONV() function. For example:<br>
?STRCONV(Hash("Some String"), 15)
</p>
<p>
<strong>Download and Code Sample<br>
</strong>As I am adding to this FLL, my examples are designed to just give you enough
so you know how to use the new functions being implemented. I will be back at a later
time with blog entries that detail the use of this FLL in real world situations
for Visual FoxPro. Here is the download link for the FLL and an example of its use:
</p>
<p>
<a href="http://www.sweetpotatosoftware.com/files/vfpencryption.zip">Download the
VFP Encryption FLL</a> (50 KB approx.)
</p>
<p>
*!* Example of Use *!*<br>
DIMENSION aryHashTypes(7) && used just for this example, not necessary in
production code<br>
aryHashTypes(1) = "SHA1"<br>
aryHashTypes(2) = "SHA256"<br>
aryHashTypes(3) = "SHA384"<br>
aryHashTypes(4) = "SHA512 (default hash type)"<br>
aryHashTypes(5) = "MD5"<br>
aryHashTypes(6) = "RIPEMD128"<br>
aryHashTypes(7) = "RIPEMD256"
</p>
<p>
CLEAR<br>
SET LIBRARY TO LOCFILE("vfpencryption.fll")
</p>
<p>
LOCAL lnCounter, lcHashDigest<br>
FOR lnCounter = 1 TO 7 && iterate through all available hashes<br>
 ?aryHashTypes(lnCounter)<br>
 lcHashDigest = Hash("Visual FoxPro Rocks!", lnCounter) && here is the
actual function in use<br>
 ?"Binary Characters:"<br>
 ?lcHashDigest<br>
 ?"hexBinary Equivalent:"<br>
 ?STRCONV(lcHashDigest, 15) && Easy way to get the hexBinary equivalent<br>
 ?<br>
ENDFOR
</p>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,99cd23d6-82b6-4a17-8385-651b3cb37e05.aspx">This post originally appeared on an external website</a></div>

Collapse -

Visual FoxPro Random License/Serial Generator

by craig In reply to The SPS Weblog

<p>
<strong>Real World Examples<br>
</strong>In <a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,99cd23d6-82b6-4a17-8385-651b3cb37e05.aspx">my
last blog entry</a> I mentioned being able to use the vfpencryption.fll in some real
world ways. While encrypting passwords and sensitve data using the ciphers, or checking
passwords and files for authenticity using hash functions are pretty well known
examples, there are others.
</p>
<p>
<strong>Generating CD Licenses<br>
</strong>What about creating software serial numbers for an application
you have developed? While I highly recommend a product like <a href="http://siliconrealms.com/index.shtml">Armadillo</a> when
you need top-notch security, a more simplified approach that is still fairly secure
can be had using a hashing function such as MD5.
</p>
<p>
<strong>Phil Fresle's Earlier Work<br>
</strong>I remembered seeing an <a href="http://www.freevbcode.com/ShowCode.ASP?ID=1639">example
of this</a> a few years back by a developer named Phil Fresle (back then his example
was simpler than it is now). And, since the vfpencryption.fll now supports MD5, I
thought I would revisit his example and see whether something of this nature could
be created for Visual FoxPro using the vfpencryption.fll.
</p>
<p>
Here is the download link and screen shot of what I came up with.
</p>
<p>
<a href="http://www.sweetpotatosoftware.com/files/vfpkeygen.zip">Download VFP Key
Generator Example</a> - source code included (80 KB approx)
</p>
<img src="http://www.sweetpotatosoftware.com/SPSBlog/content/binary/vfpkeygen.gif" border=0>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,34321a75-a1fc-4a0e-a9af-17a3c6**6d90.aspx">This post originally appeared on an external website</a></div>

Collapse -

Encryption FLL - A Fix, A Simplification, and an Additional Cipher

by craig In reply to The SPS Weblog

<p>
<strong>Important Fixes<br>
</strong>It's 4:00 AM and I have some pressing stuff that I need to get done for a
UK client. However, I did dive into the FLL again and I have fixed a couple problems
that I was alerted to by Glenn Domeracki (by the way, great job Glenn - I really appreciated
the feedback and repro code). All known issues with the FLL have been fixed.
</p>
<p>
<strong>Important Changes<br>
</strong>Also, I felt that the Hash function was so simple and elegant, that I would
try and do the same with the encryption functions. So now there are only two encryption
functions Encrypt() and Decrypt(). I will make future changes backward compatible,
but this change had to be made (it makes it far more maintainable and understandable).
The FLL has only been available on this blog for a couple of days, so I felt if I
was going to change the function signatures, now was the time.
</p>
<p>
I've also added another encryption algorithm... <font face=Tahoma>Tiny Encryption </font><font face=Tahoma>Algorithm
(TEA). It's a secure, blazingly fast, encryption algorithm. So now the FLL gives
access to: AES128, AES192, AES256, Blowfish, and TEA. And each of them is provided
in ECB, CBC, and CFB modes. So, that is basically 15 different ways to encrypt strings.</font>
</p>
<p>
<font face=Tahoma><strong>Still to Come<br>
</strong></font><font face=Tahoma>I'm still working on the EncryptFile() and DecryptFile()
functions... should be fully functional and debugged soon. But as I've mentioned in
earlier blog entries, using the STRTOFILE() and FILETOSTR() Visual Foxpro functions
in conjunction with the FLL functions will give you a way to encrypt files
until I finish the file manipulation portion.</font>
</p>
<p>
<font face=Tahoma>OK, I don't have a lot of time to document the new functions or
go into them in detail (I'll be back later), for now here is the download link for
the VFP Encryption FLL and some sample code (I hope the sample code gives you the
general idea until I can come back and detail this further).</font>
</p>
<p>
<font face=Tahoma><strong>Special Thanks to George Anescu<br>
</strong>But before I go... I can't say enough good stuff about the encryption and
hashing classes that George Anescu created. This entire project would have been 10
times as hard without the awesome amount of work he put into his C++ projects. Thanks
George, and know that it is very much appreciated that you have placed this information
into the public domain - it has allowed me to create a great derivative work for Visual
FoxPro. Make sure to read George's disclaimer that I have been including in the readme.txt
that comes with the download.</font>
</p>
<p>
<font face=Tahoma><a href="http://www.sweetpotatosoftware.com/files/vfpencryption.zip">Download
the VFP Encryption FLL</a> (58 KB approx.)</font>
</p>
<p>
<font face="Courier New" size=1>*!* Sample Code *!*<br>
<br>
SET LIBRARY TO LOCFILE("vfpencryption.fll") && contains encryption and has
functions for use in Visual FoxPro</font>
</p>
<p>
<font face="Courier New" size=1>*!* Example Keys - make your own unique keys<br>
#DEFINE A128BITKEY "!`/_b}B#JXRp}Bsn"<br>
#DEFINE A192BITKEY "fGSoTa3M?{#NOsOBGqmEd>e'"<br>
#DEFINE A256BITKEY "LVE*(zz}}'rr)`P%wDq@lc8WWbGw0[77"<br>
#DEFINE A448BITKEY ":E9}$6+a7ifN)#G')/&[ZpM$4Z.JOy@M&{^%JFOd2Ew{A?=dxB]RB9un"</font>
</p>
<p>
<font face="Courier New" size=1>*!* There are three modes for these ciphers<br>
DIMENSION aryModes(3)<br>
aryModes(1) = "ECB MODE" && Electronic Code Book<br>
aryModes(2) = "CBC MODE" && Cipher Block Chaining<br>
aryModes(3) = "CFB MODE" && Cipher Feedback</font>
</p>
<p>
<font face="Courier New" size=1>*!* AES (a.k.a. Rijndael) is the king of encryption
currently - extremely secure<br>
*!* Blowfish is popular, good mix of security and speed<br>
*!* Tiny Encryption Algorithm (TEA) is secure and extremely fast</font>
</p>
<p>
<font face=Tahoma><font face="Courier New" size=1>LOCAL lcStringToEncrypt, lcEncrypted<br>
lcStringToEncrypt = "Visual FoxPro Rocks!"<br>
CLEAR<br>
FOR lnCounter = 0 TO 2 && lets loop through all the available ways to encrypt
a string (15 in all)<br>
 ?"AES128:(" + aryModes(lnCounter + 1) + ")"<br>
 lcEncrypted = Encrypt(lcStringToEncrypt, A128BITKEY, 0, lnCounter)<br>
 ?lcEncrypted<br>
 ?Decrypt(lcEncrypted, A128BITKEY, 0, lnCounter)<br>
 ?<br>
 ?"AES192:(" + aryModes(lnCounter + 1) + ")"<br>
 lcEncrypted = Encrypt(lcStringToEncrypt, A192BITKEY, 1, lnCounter)<br>
 ?lcEncrypted<br>
 ?Decrypt(lcEncrypted, A192BITKEY, 1, lnCounter)<br>
 ?<br>
 ?"AES256:(" + aryModes(lnCounter + 1) + ")"<br>
 lcEncrypted = Encrypt(lcStringToEncrypt, A256BITKEY, 2, lnCounter)<br>
 ?lcEncrypted<br>
 ?Decrypt(lcEncrypted, A256BITKEY, 2, lnCounter)<br>
 ?<br>
 ?"Blowfish448 - 16 round:(" + aryModes(lnCounter + 1) + ")"<br>
 lcEncrypted = Encrypt(lcStringToEncrypt, A448BITKEY, 4, lnCounter)<br>
 ?lcEncrypted<br>
 ?Decrypt(lcEncrypted, A448BITKEY, 4, lnCounter)<br>
 ?<br>
 ?"TEA128:(" + aryModes(lnCounter + 1) + ")"<br>
 lcEncrypted = Encrypt(lcStringToEncrypt, A128BITKEY, 8, lnCounter)<br>
 ?lcEncrypted<br>
 ?Decrypt(lcEncrypted, A128BITKEY, 8, lnCounter)<br>
 ?<br>
ENDFOR<br>
</font>
</p>
>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,06a3d44e-c3aa-4f0d-9937-06441c59e840.aspx">This post originally appeared on an external website</a></div>

Collapse -

Southwest Fox - Speaking and Reporting

by craig In reply to The SPS Weblog

<p>
<a href="img">http://www.swfox.net/"><img alt="" hspace=0 src="http://www.swfox.net/2005/images/logo.gif" align=baseline border=0></a>
</p>
<p>
As Andy Kramek said in <a href="http://weblogs.foxite.com/andykramek/archive/2005/08/31/8**.aspx">his
most recent blog entry</a>, the conference season is upon us. I couldn't agree more
that <a href="http://www.swfox.net/">Southwest Fox</a> is THE conference to go
to this year.
</p>
<p>
I'll be there and though I'm not up on the <a href="http://www.swfox.net/Speakers2005.aspx">speaker's
list yet</a>, I will be speaking/presenting. I'll also be covering the confererence
for the <a href="http://www.utcoverage.com/Southwest/2005/">Universal Thread</a>,
so look for good daily reports by myself and <a href="http://www.softwarenewsandviews.info/WhatsInside/">Burt
Rosen</a>.
</p>
<p>
If you can find a way to attend this conference, you should. I found some great rates
on <a href="http://www.expedia.com/">Expedia</a> for flight, hotel, and car packages.
That's where I got mine anyways, and I am an avid bargain hunter.
</p>
<p>
Make no mistake, Southwest Fox is going to be huge! There is going to be a much
larger than usual Microsoft presence, the speaker list is packed with the best
of the best, and I am really looking forward to meeting everyone. Make it a point
to attend if you can. The Red Bull energy drinks and late night hotel coding/collaboration
sessions will be on me!
</p>
<p>
Hope to see you there
</p>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,a1e14248-4216-41c9-aa0d-d5413501049f.aspx">This post originally appeared on an external website</a></div>

Collapse -

Visual FoxPro - Encrypt and Decrypt Files

by craig In reply to The SPS Weblog

<p>
Work on the vfpencryption.fll continues at a steady pace (whenever a minute or two
presents itself). I've finished fixing a couple more bugs that were reported to me
and I've finished the EncryptFile() and DecryptFile() functions. Here is the download
link and some additional information regarding the FLL that will be of use to developers
who are using it.<br>
<br>
<a href="http://www.sweetpotatosoftware.com/files/vfpencryption.zip">Download the
Latest Version of the VFP Encryption FLL</a> (58 KB approx.)<br>
<hr>
<p>
</p>
<p>
<font color=#006400 size=3><strong>Function ENCRYPT()</strong></font>
</p>
<p>
<strong>Signature</strong>: Encrypt(cStringtoEncrypt, cSecretKey[, nEncryptionType[,
nEncryptionMode]])
</p>
<p>
<strong>Parameters</strong>:
</p>
<p>
<font color=#006400>cStringtoEncrypt</font> - A plain text string that you want
to have encrypted, such as "Hello World!"
</p>
<p>
<font color=#006400>cSecretKey</font> - A plain text string that is the Key you want
used during encryption, such as "My_SeCrEt_KeY".<br>
Please note that keys may need to be of a particular length for certain types of encryption.
Refer below for more information.
</p>
<p>
<font color=#006400>nEncryptionType</font> - There are currently 5 types of encryption
available. The value of this parameter determines that type of encryption used and
how long your Secret Key should be. A single character in Visual FoxPro is  equal
to 1 byte or 8 bits. So an encryption algorithm requiring a 128-bit key would need
a Secret Key of 16 characters (16 x 8 = 12.<br>
<br>
   0 = AES128 (requires a 16 character Key)<br>
   1 = AES192 (requires a 24 character Key)<br>
   2 = AES256 (requires a 32 character Key) *Default<br>
   4 = Blowfish (requires a 56 character Key)<br>
   8 = TEA (requires a 16 character Key)
</p>
<p>
<font color=#006400>nEncryptionMode</font> - There are three different modes
available for the each of the encryption types listed above. They include: Electronic
Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).
</p>
<p>
   0 = ECB *Default<br>
   1 = CBC<br>
   2 = CFB<br>
<br>
<strong>Return Value</strong>:
</p>
<p>
Character data type - the encrypted form of cStringtoEncrypt.
</p>
<p>
<strong>Remarks</strong>:
</p>
<p>
When saving the return value of Encrypt() function to a field in a table, remember
that Visual FoxPro will append blanks to the end of the string in order to fill the
character field to its designated length. This can cause problems when decrypting
the data as the spaces will be considered part of the encrypted string. To work around
this, I suggest placing a single CHR(0) at the end of the encrypted string when saving
it to the table. Then when decrypting the data just the portion prior to the CHR(0)
can be sent into the Decrypt() function.<br>
<br>
<hr>
<p>
</p>
<p>
<font color=#006400 size=3><strong>Function DECRYPT()</strong></font>
</p>
<p>
<strong>Signature</strong>: Decrypt(cEncryptString, cSecretKey[, nDecryptionType[,
nDecryptionMode]])
</p>
<p>
<strong>Parameters</strong>:
</p>
<p>
<font color=#006400>cEncryptedString</font> - A string that has been encrypted
using the Encrypt() function.
</p>
<p>
<font color=#006400>cSecretKey</font> - A plain text string that is the same Key that
you used when you encrypted the data using the Encrypt function, such as "My_SeCrEt_KeY".<br>
Please note that keys may need to be of a particular length for certain types of decryption.
Refer below for more information.
</p>
<p>
<font color=#006400>nDecryptionType</font> - There are currently 5 types of decryption
available and they correspond to the same ones available in Encrypt(). A single character
in Visual FoxPro is  equal to 1 byte or 8 bits. So an decryption algorithm
requiring a 128-bit key would need a Secret Key of 16 characters (16 x 8 = 12.<br>
<br>
   0 = AES128 (requires a 16 character Key)<br>
   1 = AES192 (requires a 24 character Key)<br>
   2 = AES256 (requires a 32 character Key) *Default<br>
   4 = Blowfish (requires a 56 character Key)<br>
   8 = TEA (requires a 16 character Key)
</p>
<p>
<font color=#006400>nDecryptionMode</font> - There are three different modes
available for the each of the encryption types listed above. They include: Electronic
Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).
</p>
<p>
   0 = ECB *Default<br>
   1 = CBC<br>
   2 = CFB<br>
<br>
<strong>Return Value</strong>:
</p>
<p>
Character data type - the decrypted form of cEncryptedString followed by a variable
number of CHR(0)s. See Remarks below for further clarification
</p>
<p>
<strong>Remarks</strong>:
</p>
<p>
<font color=#ff0000>IMPORTANT</font>: Decryption is done on blocks of memory, so when
the decrypt function returns the encrypted string it will be followed by a variable
number of CHR(0)s unless the decrypted string just happens to end at exactly the same
location as the last block decrypted. These extraneous CHR(0)'s can be removed using
a number of Visual FoxPro functions, such as STRTRAN(), CHRTRAN(), or a combination
of LEFT() and AT().<br>
<br>
<hr>
<br>
<p>
</p>
<p>
<font color=#006400 size=3><strong>Function ENCRYPTFILE()</strong></font>
</p>
<p>
<strong>Signature</strong>: EncryptFile(cFiletoEncrypt, cDestinationFile, cSecretKey[,
nEncryptionType[, nEncryptionMode]])
</p>
<p>
<strong>Parameters</strong>:
</p>
<p>
<font color=#006400>cFiletoEncrypt</font> - A plain text string that is the fullpath
to the file you wish to be encrypted, such as "C:\SensitiveInfo.doc"
</p>
<p>
<font color=#006400>cDestinationFile</font> - A plain text string that is the
fullpath to an encrypted file you wish to have created on disk, such as "C:\EncryptedInfo.doc".
If this file doesn't exist then it will be created for you.
</p>
<p>
<font color=#006400>cSecretKey</font> - A plain text string that is the Key you want
used during encryption, such as "My_SeCrEt_KeY".<br>
Please note that keys may need to be of a particular length for certain types of encryption.
Refer below for more information.
</p>
<p>
<font color=#006400>nEncryptionType</font> - There are currently 5 types of encryption
available. The value of this parameter determines that type of encryption used and
how long your Secret Key should be. A single character in Visual FoxPro is  equal
to 1 byte or 8 bits. So an encryption algorithm requiring a 128-bit key would need
a Secret Key of 16 characters (16 x 8 = 12.<br>
<br>
   0 = AES128 (requires a 16 character Key)<br>
   1 = AES192 (requires a 24 character Key)<br>
   2 = AES256 (requires a 32 character Key) *Default<br>
   4 = Blowfish (requires a 56 character Key)<br>
   8 = TEA (requires a 16 character Key)
</p>
<p>
<font color=#006400>nEncryptionMode</font> - There are three different modes
available for the each of the encryption types listed above. They include: Electronic
Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).
</p>
<p>
   0 = ECB *Default<br>
   1 = CBC<br>
   2 = CFB<br>
<br>
<strong>Return Value</strong>:
</p>
<p>
None
</p>
<p>
<strong>Remarks</strong>:
</p>
<p>
Currently the cFiletoEncrypt and cDestinationFile parameters cannot point to the same
file. This may be revised in a future version. But for safety sake, this function
requires that the original file be left untouched.
</p>
<p>
<hr>
<br>
<p>
</p>
<p>
<font color=#006400 size=3><strong>Function DECRYPTFILE()</strong></font>
</p>
<p>
<strong>Signature</strong>: DecryptFile(cEncryptedFile, cDestinationFile, cSecretKey[,
nDecryptionType[, nDecryptionMode]])
</p>
<p>
<strong>Parameters</strong>:
</p>
<p>
<font color=#006400>cEncyptedFile</font> - A plain text string that is the fullpath
to the file you wish to be decrypted, such as "C:\EncryptedInfo.doc"
</p>
<p>
<font color=#006400>cDestinationFile</font> - A plain text string that is the
fullpath to a decrypted file you wish to have created on disk, such as "C:\SensitiveInfo.doc".
If this file doesn't exist then it will be created for you.
</p>
<p>
<font color=#006400>cSecretKey</font> - A plain text string that is the same Key that
you used when you encrypted the data using the Encrypt function, such as "My_SeCrEt_KeY".<br>
Please note that keys may need to be of a particular length for certain types of decryption.
Refer below for more information.
</p>
<p>
<font color=#006400>nDecryptionType</font> - There are currently 5 types of decryption
available and they correspond to the same ones available in Encrypt(). A single character
in Visual FoxPro is  equal to 1 byte or 8 bits. So an decryption algorithm
requiring a 128-bit key would need a Secret Key of 16 characters (16 x 8 = 12.<br>
<br>
   0 = AES128 (requires a 16 character Key)<br>
   1 = AES192 (requires a 24 character Key)<br>
   2 = AES256 (requires a 32 character Key) *Default<br>
   4 = Blowfish (requires a 56 character Key)<br>
   8 = TEA (requires a 16 character Key)
</p>
<p>
<font color=#006400>nDecryptionMode</font> - There are three different modes
available for the each of the encryption types listed above. They include: Electronic
Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).
</p>
<p>
   0 = ECB *Default<br>
   1 = CBC<br>
   2 = CFB<br>
<br>
<strong>Return Value</strong>:
</p>
<p>
None
</p>
<p>
<strong>Remarks</strong>:
</p>
<p>
As with EncryptFile(), the cFiletoEncrypt and cDestinationFile parameters cannot point
to the same file.<br>
<br>
</p>
<hr>
<p>
<font color=#006400 size=3><strong>Function HASH()</strong></font>
</p>
<p>
<strong>Signature</strong>: Hash(cStringtoHash[, nHashType])
</p>
<p>
<strong>Parameters</strong>:
</p>
<p>
<font color=#003300><font color=#006400>cStringtoHash</font> - A plain text string
you wish to have hashed<br>
<br>
<font color=#006400>nHashType</font> - The type of hash function to generate. There
are currently 7 different hash functions supported</font>
</p>
<p>
<font color=#003300>1 = SHA1 (a.k.a SHA160)<br>
2 = SHA256<br>
3 = SHA384<br>
</font><font color=#003300>4 = SHA512 *Default<br>
5 = MD5<br>
</font><font color=#003300>6 = RIPEMD128<br>
7 = RIPEMD256</font>
</p>
<p>
<strong>Return Value</strong>:
</p>
<p>
Binary Character Data - the hash for cStringtoHash.
</p>
<p>
<strong>Remarks</strong>:
</p>
<p>
The hash is returned as a series of binary characters. However, it is more
common to see hashes in a hexBinary format. This can be accomplished in Visual FoxPro
by taking the return of the Hash() function and sending it in as a parameter to the
STRCONV() function. For example:<br>
<br>
?STRCONV(Hash("Some String"), 15) && hexBinary Hash<br>
</p>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,db662a8f-d47c-46c8-b0d2-a591c20d024b.aspx">This post originally appeared on an external website</a></div>

Collapse -

Encrypt/Decrypt File Fix

by craig In reply to The SPS Weblog

<p>
Steve Tootill reported that the DecryptFile() function was not working for dbf's.
On closer inspection, I found there was a problem with the original Visual C++ code
that was written by George Anescu from which the encryption and decryption features
of the vfpencryption.fll is derived.
</p>
<p>
The problem is that basically George just returned entire decrypted blocks and didn't
take into consideration the original file size. To fix this I have added a single
byte to the end of the file before it is encrypted that tells the decryption functions
how long the original file is. This byte is read into memory and the decrypted file
is sized appropriately... thus eliminating the extraneous padding characters from
the end of the file. For more detailed information regarding this FLL please refer
to my earlier post:
</p>
<p>
<a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,db662a8f-d47c-46c8-b0d2-a591c20d024b.aspx">Visual
FoxPro - Encrypt and Decrypt Files</a>
</p>
<p>
Here is the latest download for the VFP Encryption FLL (NOTE: all downloads on this
weblog for the VFP Encryption FLL point to the latest version)
</p>
<p>
<a href="http://www.sweetpotatosoftware.com/files/vfpencryption.zip">Download VFP
Encryption FLL</a> (58 KB approx.)
</p>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,f7607460-b50d-4ecc-b39b-470e9ba5c490.aspx">This post originally appeared on an external website</a></div>

Collapse -

VFP Random Password/Key Generator

by craig In reply to The SPS Weblog

<p>
Today I'm working on the Encryption/Decryption session I will give at <a href="http://www.swfox.net">Southwest
Fox</a>. And, while I was on the subject, I thought it would be nice if there was
a simple way to produce random cryptography keys of a required bit length for certain
encryption algorithms. So, I decided to create one in Visual FoxPro 9.0. It took all
of about 10 minutes from start to finish and provides a pretty decent way to create
random keys. Here is the download link and the customary screen shot.
</p>
<p>
<a href="http://www.sweetpotatosoftware.com/files/vfppasskey.zip">Download VFP Password/Key
Generator Example and Source</a> (29 KB approx.)
</p>
<img src="http://www.sweetpotatosoftware.com/SPSBlog/content/binary/vfppasskey.gif" border=0>
<br />
<hr />
This weblog is sponsored by <a href="http://www.sweetpotatosoftware.com">SweetPotato
Software, Inc.</a><p><div class="blogdisclaim"><a href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,45765bed-849a-4988-853c-3cfd8759e4e9.aspx">This post originally appeared on an external website</a></div>

Back to After Hours Forum
94 total posts (Page 4 of 10)   Prev   02 | 03 | 04 | 05 | 06   Next

Related Discussions

Related Forums