Guidance
指路人
g.yi.org
software / rapidq / Examples / String & Text / Encryption / encrypt1 / encrypt1.htm

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Encrypt1

Text File Encryption with Rapid-Q - Part I

Overview

Scrambling a text file with an encryption routine can provide privacy and control over who can read the data. This example shows how text can be encrypted in a basic way to give this privacy. A password is used to encrypt and decrypt (unscramble) the data so if an incorrect password is used, the information will not properly decrypt. This example is for illustration purposes. Here is what it does not do - It does not encrypt entire files, it does not perform any file input/output, and it does not have any GUI interface. This is merely an "engine" that does the job and can be adapted to your particular needs.

Possible Uses

Here are a few ways this could be implemented… a "hard coded" routine inside a program to encrypt and decrypt text strings before you write them out to disk or after you read them from disk. In this manner, the DOS "type" command , or Windows notepad, would only show garbage, and the data could not be intelligibly read unless your program was used. <or>…a stand alone program that prompts you for what file to encrypt, the encrypted file name, the password, and perhaps a checkbox that deletes the unencrypted file of course. <or>…a subroutine/function in a separate "include" file that could be called by any program, passing it the string to encrypt and a password; or this function could be passed an entire filename and password. There are more variations to these methods, and that is why I have only included the "engine" for an example. Now you can still have fun implementing this in your own way.

Disclaimer

I have no idea how easy it is to "crack" this routine and I can't tell you how many "bit" encryption it is. I do know that without the correct password, it will not unscramble. Beware how you adapt your programs to use this. If you forget the password, I am not able to help you. If you overwrite or remove your original text, data, or file or cannot unscramble any of these, I cannot be held responsible. The program that I wrote does work, and the examples show the string before and after encryption, and again after decryption. Any adaptations you make to these conceptual ideas are your responsibility, not mine, not William Yu's, and not Rapid-Qs. You are on your own and responsible for your own code.

History

Here is the background on this routine. I developed this in 1986 with some input from "Mark" who is a friend of mine. This was developed in "data basic" on the PICK System (Ultimate version). In 1996, I adapted it as a standalone 32 bit program with prompts and a GUI interface in the O'Basic language, which is not receiving much attention these days from its developer. Someone on the OB bulletin board told me about Rapid-Q, which brought me here to enjoy more benefits and share this with you.

The Code Explained

The code is enclosed separately from this page, called "crypt101.bas", and I will briefly explain it for those who want to read about it. It works like this… we loop through the text string, take each individual character's ASCII equivalent, add a number to it and convert this number back to a character. That's it. The number we add varies and that is the where the password fits into the encryption. We take the position of our character in the overall string (1, 2, or 3, etc), divide it by the length of the password, and use the remainder to get that character position from the password. We get the ASCII equivalent from that password character and that becomes our number to add. Try using different passwords and you will see different results. Notice if the password is too short, you may get repetitions, whereby every similar letter has the same encryption character. This is not good and is easier to figure out, like a child's puzzle. Have a longer password if this occurs. The characters produced by the encryption should be varied and jibberish. The characters happen to look like graphics characters because they are above the ASCII numeric range of our normal alphabet. I call them Chinese swear words because it looks more like Chinese writing than the @#*$% American swear words. No offense is intended for anyone with this attempted humor.

Summary

Please enjoy the code and contribute your own adaptation of this to the knowledge base, in the interest of our intellectual cause.

The End.

created by "Scott" 5/28/00 SandDune@maine.rr.com

掌柜推荐
 
 
¥1,420.00 ·
 
 
¥950.00 ·
 
 
¥288.00 ·
 
 
¥738.00 ·
 
 
¥397.00 ·
 
 
¥750.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:57:23