CryptPad Program

Encrypting Editor Notepad Replacement

C# .Net 3.5 (Windows 7)
Windows Forms Application
with source code

Version 2.8 Released 2014-06-01

/Home /Professional /Papers /CryptPad

Cryptpad Program Version 2.7 released 2014-04-06


Download Program and Source

CryptPad.zip

CryptPad-SourceOnly.zip


Contents

Introduction

I love Windows Notepad! I write all my HTML, Jscript, CMD scripts, and much more in Notepad. It is my favorite editing tool. It is fast and simple. So, why would I write a replacement program?

The primary purpose of the CryptPad program is to provide optional file encryption. This is valuable for files which contain sensitive information. Unlike many other encryption solutions, this one requires no installation, is very simple, and non-intrusive on the operating system. CryptPad only encrypts and decrypts one file at save and open. There is never a decrypted version of the file stored unless the operator specifies to remove the encryption. The file can be stored multiple places and moved freely like any other file, but always in encrypted form. Anyone who knows the encryption string can read the file with this program.

You may refer to the section on Encryption for additional details.

It is important, for better security, to use different passwords on each website you visit. In order to maintain these multiple passwords, I have a file with all the passwords in it that I use. This is also a security risk unless the file is encrypted. I have examined many encryption solutions and none does exactly what I need. I need to be able to transport and store an encrypted file anywhere I want. Encrypted drives are not what I need. The file must never exist in decrypted form. Therefore I need a simple editor which opens, decrypts, edits, encrypts, and saves a file.

I also want the encrypted text to remain plaintext and not binary so that the operator can use the encrypted text anywhere (such as by copy and paste) you can use plaintext. I also want the size of the data to remain as small as practical. Therefore, special encodings of binary encryptions do not serve my purposes.

You might notice my use of the word "operator". I am a little uncomfortable with the word "user". I am deeply steeped in the computer industry having worked over 40 years with computers since about 1971. I remember the use of the word "luser" (loser) by those educated ignoramuses who considered their priesthood as above the lowly computer user. There is also the unfortunate association with the phrase "drug user". Sensitivity may not be considered a "manly" trait but I treasure and practice this characteristic. I evaluate the use of words just as carefully as I evaluate the computer software I use and write.

Notice that I do not at any point describe CryptPad as a Notepad clone. A clone is an exact copy. Notepad has some very specific functionality, which I have not seen any simple Notepad clone duplicate completely. For example, the Undo function of Notepad has not been properly implemented in most advertised "clones". Undo is implemented wherever practical in CryptPad. I have also not seen a simple "clone" which properly implements UTF-8 and Unicode conversions or reads files with ANSI characters as Notepad and CryptPad do. Major Notepad replacement programs such as Notepad++ will support these character encodings.

CryptPad is intended to be nearly the same as Windows 7 Notepad. I have chosen not to include the printing function. I almost never use paper or printing! Those rare occasions when I might want to print I can just use Notepad. CryptPad is not a "clone" but is close enough to be a useful replacement. Now that I have created the source code for a replacement for Notepad, I have been adding functions useful in my daily editing work.

I also have a major problem with Notepad because it allows a problem I call parallel update. In parallel update, you already have a file open with edits but it goes to the background when you switch windows. Later you open the file again forgetting that you already had it open. You make new edits and close the file. You switch to the old window later forgetting (Is this forgetting because I have been programming for over forty years?) you had changed it in a new window and save it again. Your previous edits are lost! There are several sequences of events that can lead to data loss. The situation is even worse if you edit a file on a network share and somebody else edits the same file!

Unlike Notepad, CryptPad maintains the file in an opened state locked against parallel changes but shared with file readers. This protects the file against accidental parallel modification data loss problems. I have had this happen to me on occasion with Notepad. You can still lose changes but it will have to be by a deliberate sequence of actions and not by casual accident.

Cryptpad contains many small improvements and special tools beyond what Notepad provides useful for editing. The most significant other addition is the optional use of .NET Framework Regular Expression Synatx for Find and Replace.

I hope you find the CryptPad program useful. I am interested in any problems you may find in the program and in particular any incompatibility as a Notepad replacement. I intend to keep the program as small and simple as practical. CryptPad will always be a switchblade not a Swiss Army knife.

I continue to use, modify, and test the CryptPad program. I will return periodically (every other month or so) to update this article and the source code with the latest fixes, improvements, and tweaks.

ASCII, ANSI, UTF-8

As you read about this program, you might like to ask me a question. What in the world is all this UTF-8 and Unicode nonsense!?

In the old days of microcomputers (about 1980), it was simple. (It wasn't really. Remember EBCDIC? But we will pretend it was simple.) All text files were 7 bit ASCII (American Standard Code for Information Interchange) characters. Notice the word "American" in ASCII. There are many people in the world, with many different languages and characters, and they need to be represented in daily computer use. There are also additional "American" characters in common use beyond plain ASCII.

There is a great deal of confusion about the subject of character encoding. If you are a detail oriented person and prepared for a heavy read, you can start here:

http://en.wikipedia.org/wiki/UTF-8

I will try to make it short and simple. When you are using typical ASCII characters, strict UTF-8 (without a BOM) is exactly the same thing. Most of your editing will be simple ASCII. This entire webpage is only ASCII. In most cases, you can just stop here.

The exception is for non-English languages and if you ever use characters such as Microsoft Word smart quotes and apostrophes. These are the "curved" typographical equivalents of the simple "straight" ASCII quote and apostrophe. The apostrophe has a curve and there is a different curve for beginning and ending a quote. There are many other types of special characters. Many of the other languages also require special characters.

There are two primary ways to represent these types of non-ASCII characters. The older way is with single 8 bit characters. This is when you see "Windows-1252" or other non-Unicode encodings. These encodings can be very complex and plagued with limitations. Notepad refers to this as "ANSI" encoding. Unicode makes the process simpler (but not simple) to support everybody's characters. UTF-8 was invented to support ASCII with no changes and optionally extend to Unicode characters using pairs or clusters of 8 bit characters.

If this short explanation made you curious to know more, then you are back to the heavy reading I mentioned earlier. You may also refer to the section on Encoding for additional details.

Installing the Program

An important feature of this editor is that it does not require a blind install program or administrator permission. I am using the term "blind" to refer to the fact that the extent of the changes made by the typical install program are completely hidden from you. I don't like things that are hidden.

The CryptPad program is completely stand-alone so a simple copy is the minimum needed to permanently "install" and use the program. You can carry it on a USB flash drive and use anywhere with Windows 7 or later. You can use it temporarily, anywhere, and immediately with no install, no permissions, and no problems directly from the USB flash drive.

At this point I should mention that the CryptPad program uses standard .NET persistent settings. The persistent settings are things like Word Wrap, Font, Status View, and Window Position. These settings are stored in a file named user.config, which is kept in a directory with a name similar to "%LOCALAPPDATA% (C:\Users\%USERNAME%\AppData\Local) \Frank_T_Clark_Software\CryptPad.exe_Url_*\". These settings are kept in a separate unique directory ("CryptPad.exe_Url_*") generated by Windows depending on the CryptPad version and where the program is run from.

The permanent CryptPad program "installation" location is recommended for a CryptPad directory under the Documents directory for an individual operator. This would be a directory named "%USERPROFILE% (C:\Users\%USERNAME%) \Documents\CryptPad". Just create the directory and copy the program into place. You could download the CryptPad.ZIP file to the Documents folder and extract into this directory. The download provides a documentation/help file, image file, and useful scripts, which can also be placed in this directory. The help file is also available online and may contain additional updated information.

If you wish, "Open With" can be set to default to CryptPad for the .SAFE encrypted files created by CryptPad. You might choose to set the default "Open With" to CryptPad for .TXT also to take advantage of the additional editing functions.

I do not provide a blind install program because I want you to know for absolute certain exactly what is required to use the program. Uninstall is very simple. Erase the program! Most Setup programs mysteriously make unknown changes to your computer. I won't even blindly change the registry for you. I do provide a readable CryptPadInstall.CMD script and a CryptPadAdd.REG file, which illustrates an install procedure you can use.

The CryptPadAdd.REG file used by the CryptPadInstall.CMD script contains all kinds of settings I use to make CryptPad the default editor. These have been used and tested on Windows 7. I now use CryptPad to edit everything where I would have used Notepad. I recorded the registry changes with the "Default Programs Editor" freeware download, which works great. It is highly recommended.

The CryptPadAdd.REG file contains registry entries to associate the CryptPad program as the default editor for the .SAFE and .TXT file types. The .HTML, .CMD, and .REG file types have a Context Menu (Right-Click) "Edit" option. All these file types also have a Context Menu option "Open (Read-only)". There is a CryptPadDelete.REG file, which contains delete codes for these registry entries. The CryptPadInstall.CMD file automatically copies the CryptPad program to the default "install" location and runs Regedit. The Install CMD script can also be run from the "install" directory to only add registry entries.

The "Program Files" directory can be used for an administrator install for all operators. This is supported by the provided "install" scripts. When the program is installed in the "Program Files" directory in a secure environment, it does not need special permissions for normal use. There is never an attempt made to write to the directory where the program is installed during normal operation of the program. The CryptPadInstallAdmin.CMD, CryptPadAddAdmin.REG, and CryptPadDeleteAdmin.REG files support administrator install and modification of the registry for all operators.

The administrator install option has not been well tested because I rarely use administrator permissions. I was not able to get the install script to work on Windows Server 2008, but I didn't try very hard. A manual install was quite simple. Just copy the files and click CryptPadAddAdmin.REG. Even on my own personal computer I rarely use administrator permissions. The individual operator install has been heavily used and tested both in my workplace and at home.

I provide the complete source so you can know for certain exactly what the CryptPad program does. Compile it for yourself, if you want. Examining the code is not easy, unless you are already a C# programmer, but it is available, if it is a concern to you. By these methods, you can trust the software. There is so much out there that is not trustworthy. You don't have to trust me. Full disclosure is the best trust there is.

The CryptPad program is a C# Windows Forms application compiled in VS2010 Express with the .NET framework version 3.5, which is included automatically with the Windows 7 OS. The program requires nothing but the supplied source and standard Windows functionality with VS2010 Express. The program has only been well used and thoroughly tested with the Windows 7 OS. I tried to upgrade to VS2013 Express but there is a problem in the new version which keeps me from easily upgrading.

The CryptPad program has only been used a little with the Windows 8 OS (Yuck!). Maybe Windows 8.1 will be better...

The CryptPad program has not been used or tested with Windows Vista (another Yuck!) or XP. Unfortunately, the .NET framework version 3.5 is not installed in Windows Vista or XP so you will need to install it to use the program in Windows Vista or XP. There are likely to be issues with the program on these operating systems. I don't use Windows Vista or XP anymore so I won't be able to help you.

Using the Program

Perhaps it will be helpful for me to describe a step by step procedure for creating an encrypted file.
  1. Start the CryptPad program.
  2. Select File, Encryption
  3. Enter your encryption string and type the Enter key.
  4. Enter the same encryption string again and type the Enter key.
  5. Enter your data.
  6. Save your file.
  7. If you open the encrypted file in Notepad you will see "~!@#" and more nonsense characters. Close the file without making any changes.
  8. Open the encrypted file in CryptPad.
  9. Enter your encryption string and type the Enter key.
  10. There is your data...

You may also add CryptPad encryption to an existing text file.

  1. Open any text file with the CryptPad program.
  2. Select File, Encryption
  3. Enter your encryption string and type the Enter key.
  4. Enter the same encryption string again and type the Enter key.
  5. Save your file.

It is also simple to remove CryptPad encryption from an existing encrypted text file.

  1. Open any encrypted text file with the CryptPad program.
  2. Enter your encryption string and type the Enter key.
  3. Select File, Encryption
  4. Enter a blank string
  5. Enter a second blank string
  6. Save your file.

The installation and use of the CryptPad program is NOT designed for the casual or novice operator! If you follow the instructions carefully, you will be able to install and use the program. The CryptPad program is as simple to use as Notepad. The minimum copy installation is very simple. Using "Open with" is not very hard either.

The readable CryptPadInstall.CMD and CryptPadAdd.REG files are also available to make a complete "install" of the CryptPad program. These have been carefully tested on the Windows 7 operating system.

Warning! The optional use of the CryptPadInstall.CMD and CryptPadAdd.REG files requires a high level of knowledge and sophisticated skill to understand the changes they make. You can do significant damage to the function of the Windows operating system using a .REG file which is just like using the Registry Editor. All the warnings you have seen about the dangers of the use of the Registry Editor apply to using a .REG file. You are usually safe using a prewritten .REG file created by a knowledgeable developer. You are usually safe when you carefully follow instructions created by a knowledgeable developer.

You are invited to go the Code Project (www.codeproject.com) forum where the CryptPad program is published to leave comments. Registration is required. Code Project is a gathering place for millions of software developers.

Using the Code

I am providing the complete VS2010 C# project zip file with the executable, documentation, and the complete source code for CryptPad, the encrypting editor Notepad replacement program for those who enjoy software code. You might be interested in adding your own special functionality.

I hope you find the source code instructive for picking up some ideas. I have learned a lot by examining the code of others. I hope examining my code will be useful to you.

The project contains numerous test files and various things I found useful to develop, test, and use CryptPad. Of particular interest are the "CryptPad (read-only)" and the "SendTo" shortcuts. Clicking the "SendTo" shortcut opens the directory where these shortcuts reside. You can drag and drop the "CryptPad (read-only)" shortcut on the "SendTo" shortcut to add a new item. There are many interesting and useful things you can do with the "SendTo" directory.

It is also particularly important to mention the CryptPadAdd.REG file. This file contains registry entries to provide the Windows Explorer, context menu, "Open With", type of associations to use CryptPad with various file extensions. You must edit the CryptPad.REG file to provide the location where the CryptPad.exe file is kept, if you do not use the recommended "Documents\Cryptpad" directory. Some of the entries provided by the CryptPadAdd.REG file cannot be duplicated by using only the "Open With" association functionality.

Warning! The use of a .REG file requires a high level of knowledge and sophistication. You can do significant damage to the function of the Windows operating system using a .REG file which is just like using the Registry Editor. All the warnings you have seen about the use of the Registry Editor apply to using a .REG file.

Points of Interest

One of the many interesting features in the CryptPad program source code is the automatic detection of ANSI, UTF-8, and Unicode character encodings with Byte Order Mark (BOM) detection. This is a feature missing out of the simple Notepad "clones" I have seen. One of them implements it now because I told the writer how to do it. The .NET library provides all the support needed for automatic detection but doesn't tell you how to use it.

There are two pieces of information required and some sample code to demonstrate their use. I have seen many complicated solutions proposed for automatic detection but it is actually quite simple. I will mention that my assumption is that the file is properly encoded without encoding errors or malformed characters. This is a reasonable assumption for any properly written program (such as Notepad and CryptPad) used to create a file.

The first piece of necessary information is to recognize that the UTF-8 encoding has been carefully designed for automatic detection, which makes it vastly different than the complexities and ambiguities of ANSI encoding. It is highly unlikely (but possible) that an ANSI file would be mistaken as UTF-8. The other detection methods don't promise any better. I won't go into detail about this feature of the UTF-8 encoding.

The second piece of necessary information is to recognize that the .NET library implements automatic detection through exception handling when ANSI characters are found. Unfortunately, the documentation doesn't connect the dots for how to implement this automatic detection.

This sample code illustrates automatic detection of UTF-8 and other Unicode encodings with an exception handling fallback to ANSI encoding.

This simple (assuming you are a skilled C# programmer) example excerpt is not identical to the supplied source code.

file_stream = new FileStream (filename, FileMode.Open,
FileAccess.ReadWrite, FileShare.Read);

// UTF-8 encoding with automatic dection of other
// Unicode encodings and ANSI error detection
Encoding save_encoding = new UTF8Encoding (false,true);
StreamReader sr = new StreamReader (file_stream,
    save_encoding, true);

string str = null;
try
{
    str = sr.ReadToEnd ();
    // Save the actual encoding for later write
    save_encoding = sr.CurrentEncoding;
}
catch
{
    // ANSI error detection
    save_encoding = null;
}
if (null == save_encoding)
{
    // use ANSI from the default code page
    save_encoding = Encoding.GetEncoding (0);
    file_stream.Position = 0;
    sr = new StreamReader (file_stream,
save_encoding);
    str = sr.ReadToEnd ();
}

... modify str

// discard any previous contents
file_stream.SetLength (0);

// use StreamWriter with the same encoding
StreamWriter sw = new StreamWriter (file_stream,
    save_encoding);
sw.Write (str);

The most novel aspect of the CryptPad program source code is the encryption. The program uses a quick and simple double scrambling algorithm of addition/subtraction based on a secret encryption string provided by the operator. The program encrypts only ASCII so that I have a contiguous arithmetic range. My apologies to those whose language is not based on ASCII. The intent is to continue to use text rather than binary processing. The encryption is highly efficient and adds only 21 bytes to the size.

It is possible to use Base64 or similar encoding to convert the entire Unicode string to ASCII for the encryption. This would add a lot of overhead in processing and size. Using any standard encryption would have the same effect. These other methods would also add a lot of complexity to the program. This quick, simple, and effective solution serves my purposes the best.

These simple example excerpts are not identical to the supplied source code.

private string Encrypt (string str)
{
    StringBuilder st = new StringBuilder (str);
    for (int i = 0; i < st.Length; ++i)
    {
        int chr = st[i];
        if (isASCII ((char)
chr))
        {
            chr
= ' ' + (((chr - ' ') + E (i)) % 95);
            st[i]
= (char) chr;
        }
    }
    return st.ToString ();
}

private string Decrypt (string str)
{
    StringBuilder st = new StringBuilder (str);
    for (int i = 0; i < st.Length; ++i)
    {
        int chr = st[i];
        if (isASCII ((char)
chr))
        {
            chr
= ' ' + ((chr - ' ') - E (i) + 95) % 95;
            st[i]
= (char) chr;
        }
    }
    return st.ToString ();
}

The encryption string is scrambled with a pseudo-random number seeded with a checksum of the encryption string

private int E (int i)
{
    return (encryption_string[i %
encryption_string.Length]
        + i + i * random_seed) %
95;
}

// plus checksum for random_seed
private int ChecksumAdd (string str)
{
    int checksum = 0;
    for (int i = 0; i < str.Length; ++i)
    {
        checksum += str[i];
    }
    return checksum;
}

The CryptPad program uses an additional XOR checksum placed in the file to verify whether the encryption string is correct when attempting to decrypt. I protect short encryption strings by extending it to at least 32 characters. The purpose is to protect the operator from a wrong decryption and warn them, if they mistype the encryption string.

// xor checksum for in the file
private uint ChecksumXOR (string str)
{
    uint checksum = 0;
    int j = 32;
    if (32 < str.Length)
        j = str.Length;
    for (int i = 0; i < j; ++i)
    {
        uint t = 0;
        if (0 < (0x80000000 &
checksum))
            t
= 1;
        checksum <<= 1;
        checksum |= t;
        checksum ^= str[i %
str.Length];
    }
    return checksum;
}

I use a second XOR checksum to detect whether the encrypted data has been corrupted by being modified without being decrypted. This would destroy the integrity of the encrypted data. The operator would be notified immediately upon attempting to open the file whether the encrypted data had been modified and corrupted. If the '~!@#$' encryption header is modified, then the data is assumed to be non-encrypted and displayed without decryption.

I would not claim the encryption used by the CryptPad program is CIA quality but I think you will find it is highly effective. The strength of the encryption is highly dependent on the length of the encryption string. A strong string of ten characters or more is not likely to be broken by anyone except a skilled cryptologist. I am not a skilled cryptologist but I am familiar with some aspects of cryptology. The primary attacks against this encryption have been anticipated.

I am offering a challenge to see if a clever hacker or skilled cryptologist will take an interest and break my encryption. I have included a file called "hack.safe" in the zip file. If you can break my encryption, please post the results in the discussion with the encryption string. Anyone can verify your success. I would be interested to know how you did it, how long it took, and what type of equipment was needed.

The most likely attack would be against the XOR checksum used to verify the encryption string against typographical error. The success of this type of attack depends on the strength of the encryption string you choose.

The suggestion has been made that I should use the File.Encrypt method. I do not want a decrypted version of the file to ever reside on any drive for any period of time. I want to be able to carry the file anywhere I want and use anywhere I want. CryptPad.exe can be carried with the encrypted file (such as on a USB drive) and used anywhere to read the file without any installation or removal and there is never a trace of the decrypted file on the computer (Well, maybe in memory or in the paging file...). I want the encryption to be text that I can copy and paste anywhere. The File.Encrypt method does not meet any of those criteria. I have seen nothing that meets these criteria.

The suggestion has also been made that I should use an industry defined standard encryption method. This would result in binary files. I want to use only methods that produce plain text so that the encryption can be pasted into email, instant messages, and wherever plain text would normally be used. It is possible to Base64 encode the result. I do not wish for the file size to increase by a significant amount. Standard encryption methods also increase the complexity and processing of the program.

Those who wish to use an industry defined standard encryption method and support Unicode can modify the program to their requirements. I am happy with a simple and fast ASCII encryption process.

What Is Notepad?

Notepad is the basic text editing tool provided by the Windows operating system to view or edit plain text files. A text file is a file type typically identified by the .TXT file name extension. There are other extensions which contain text, which I often edit with Notepad.

Notepad has several specific important characteristics to note beside the fact it is a plain text editor. Probably the next most important characteristic of Notepad is that the entire file is completely loaded into memory while editing. This makes Notepad fast for the typical file of about 64k or less. However this is a problem when editing multi-megabyte files. The good news is that Windows 7 Notepad and CryptPad can do it but the bad news is that it slows down pretty quickly. You usually don't need to do this very often.

Another important characteristic is that it supports all the standard file encodings. ANSI, UTF-8 (ASCII), Unicode (UTF-8), Unicode, and Unicode (Big-Endian).

What Is Windows Explorer?

It is important to understand that Notepad is tightly integrated with Windows Explorer. The CryptPad program can also be tightly integrated with Windows Explorer. Windows Explorer is my primary development platform or environment for general purposes. Most developers understand this. A beginning computer operator may not understand the importance of Windows Explorer, which is also known as "My Computer". Many people use the "Desktop" as their primary launch platform. The "Desktop" is actually a simple view of Windows Explorer. I primarily use Windows Explorer as my launch platform.

The first thing I always do on a new computer is enable the icon for "My Computer" on the "Desktop". I also always rename it to the name of the computer because I remote to so many computers so often, it helps to have a little reminder of what computer I am using. Many times the first thing I click on the desktop is "My Computer" or Windows Explorer.

I am very particular about how Windows Explorer is configured. It is vitally important that all file information be displayed. The second thing I always do on a new computer is enable file details in Windows Explorer. The third thing I do is change the default Layout to show the Navigation pane. I also like the Details pane.

What Is Plain Text?

All files can be placed in two general categories. Text files are designed primarily to be read by a person. Binary files are designed primarily to be read by a computer program. Binary files may contain text but text files almost never contain binary data.

A proper plain text file contains only printing characters designed to be read by a person. The file will contain the ASCII CR/LF control characters to indicate the end of a line and the ASCII HT (TAB) control characters to arrange text in columns. Any other ASCII control characters are improper. Some of the ASCII control characters are actually encoded to a printable Unicode character. It is also improper in a typical Windows file for there to be ASCII CR or LF control characters which are not part of a CR/LF pair.

What Is the TextBox?

Notepad is based on the Windows TextBox control which provides most of the editing functionality. Notepad and TextBox are both a bit short on documentation for their functionality but are mostly simple. The Help option in Notepad does little more than provide answers to some common simple questions about Notepad. At least the pieces of Notepad functionality are listed in the menu options. There are a lot of questions left unanswered about how the functions are performed. This documentation file answers those questions for the CryptPad implementation of Notepad functionality.

TextBox is the primary input control for Windows. Almost all other Windows input functionality either expands or imitates the basic functionality of TextBox. I am providing some additional description about editing with the TextBox in the CryptPad Help and website documentation.

How is CryptPad different?

The basic use of CryptPad is mostly identical to Notepad. The design of the CryptPad program is similar to Notepad. CryptPad is also based on the TextBox control. The primary difference of CryptPad from Notepad is a lack of support for printing. You may use Notepad, when you wish to print. CryptPad adds support for encryption, file locking, .NET Framework Regular Expression Synatx, and automatic backup. CryptPad provides other functionality beyond Notepad.

Cryptpad describes its functionality in more detail than Notepad provides. The documentation assumes you know how to use Notepad so it primarily describes what is different from Notepad. The documentation also describes some of the more mysterious operations it shares with Notepad. The computer elite love murky software operation, which needs to be researched to discover and then remembered. I believe in documentation, which is disdained among many of those who consider themselves skilled in computer usage and software development. Maybe they can't or won't read plain English and assume nobody else does either.

CryptPad uses the operator specified Message Box system font and size in all CryptPad dialogs. Those with young good eyes can use the default 8pt or whatever while those with older poor eyes can use Control Panel, Personalization, Window Color and Appearance to specify what we need. I prefer Verdana 12pt. This works fine on Windows 7 but Microsoft in their great wisdom does not appear to allow us to specify our own font on Windows 8! Changing the font size on Windows 8 is also awkward, as is much of Windows 8. (Did I already say? Yuck!) Who do I complain to that will listen and do something for the handicapped or visually limited?

The most useful functionality for developers is the error checking for misplaced control characters and other checking and correcting functions. CryptPad is also more helpful and functional than Notepad without loosing the basic simplicity and speed.

Release History and Notes

A history of changes to the CryptPad program and release notes.
  • Version 2.8 Released 2014-06-01:
    • Corrected the special functionality of "Replace All" when there is only a single non-RegEx replacement.
    • Improved the documentation of the RegEx implementation after further use and testing.
    • Other minor documentation improvements.
  • Version 2.7 Released 2014-04-06:
  • Version 2.6 released 2014-02-09:
    • Changed the handling of the current directory.
    • Added a conversion to support using the echo command to create a quote in an automation script. In this case you may use "\q" to indicate a quote.
    • Improved RestoreCaretPosition function and corrected occasional exception errors when the number of lines changes and the current caret position is near the end of the document.
  • Version 2.5 released 2013-12-08:
    • Window Position Setting fixed.
    • Saved the Replace string on a Find Next so it is not lost, if followed by a Cancel.
    • Rearranged code a little bit to more accurately group related functions.
    • I did some tweaks of control spacing on the find and replace dialogs.

TextBox Mouse/Keyboard Actions

In order to better understand and describe the actions of the mouse and the keyboard in the TextBox we need to define some terms.
Caret
The position in a TextBox where the next character typed on the keyboard will be inserted. This position is marked with a blinking vertical bar.
Pointer
The cursor displayed by the mouse, which marks where the action of a mouse click is applied. When the cursor is over the TextBox it is usually shaped like a tall and thin capital letter "I" known as the I-beam.
Word
The definition of a "word" is complex but important to understand wrap and other functions. Generally speaking a "word" of text begins after a space, question mark "?", exclamation mark "!", closing brace "}", closing bracket "]", closing parenthesis")", vertical bar "|", and hypphen "-" or before a dollar sign "$", percent sign "%", plus sign "+", backslash "\", opening brace "{", opening bracket "[", and opening parenthesis "(".

The hard newline is both a before and after word break character but is a word itself and is never included in another "word". Multiple word break characters are usually combined and included in the definition of the "word". Only one leading word break character of dollar sign "$", percent sign "%", plus sign "+", and backslash "\" is included in the definition of the "word". Punctuation such as single/double quote, comma, colon, and semicolon before and after a word break character is included in the definition of the "word". Confusing?

These are some of the mouse shortcuts used in a TextBox. It is impossible to know if this is a complete list without adequate Microsoft documentation or careful testing.
Click
Move the caret to the current location of the mouse pointer.
Right-Click
Pop-up up the context menu.
Double-Click
Select the "word" under the mouse pointer.
Click-Drag
Select the text under the beginning location of the mouse pointer through the final location of the mouse pointer.
Double-Click-Drag
Select the "word" under the beginning location of the mouse pointer through the "word" under the final location of the mouse pointer.
Shift-Click
Select the text from the caret to the pointer.
Shift-Double-Click
Select the text from the caret to the "word" at the pointer.
This is a list of the TextBox keyboard shortcuts grouped by function. It is impossible to know if this is a complete list without adequate Microsoft documentation or careful testing.

Moving the Caret

Right
Move the caret one character position to the right.
Left
Move the caret one character position to the left.
Up
Move the caret one line up.
Down
Move the caret one line down.
Home
Move the caret to the beginning of the line.
End
Move the caret to the end of the line.
PageUp
Scroll the TextBox window down placing the top line on the bottom line and keeping the caret at about the same position in the window.
PageDown
Scroll the TextBox window up placing the bottom line on the top line and keeping the caret at about the same position in the window.
Ctrl+Right
Move the caret right to the start of the next word position.
Ctrl+Left
Move the caret left to the start of the previous word.
Ctrl+Home
Move the caret to the beginning of the text.
Ctrl+End
Move the caret to the end of the text.

Selecting Text

Shift+Right
Extend selection one character to the right.
Shift+Left
Extend selection one character to the left.
Shift+Down
Extend selection down one line.
Shift+Up
Extend selection up one line.
Shift+Home
Extend selection to beginning of line.
Shift+End
Extend selection to end of line.
Shift+PageUp
Scroll the TextBox window down placing the top line on the bottom line and keeping the caret at about the same position in the window extending the selection.
Shift+PageDown
Scroll the TextBox window up placing the bottom line on the top line and keeping the caret at about the same position in the window extending the selection.
Shift+Ctrl+Right
Extend selection to next word.
Shift+Ctrl+Left
Extend selection to previous word.
Shift+Ctrl+Home
Extend selection to top of text.
Shift+Ctrl+End
Extend selection to bottom of text.

Cut, Paste, and Undo

Ctrl+C, or Ctrl+Ins
Copy selected text into the clipboard.
Ctrl+V, or Shift+Ins
Paste selected text from the clipboard.
Ctrl+X, or Shift+Del
Cut selected text into the clipboard.
Ctrl+Z
Undo last edit.

Deleting Text

Del
Delete the character right of the caret or the current selection.
Backspace, or Ctrl-H
Delete the character left of the caret or the current selection.
Ctrl+Del
Delete to the end of the line or the current selection.

Inserting Text

Any ASCII graphic character
Insert the character typed at the caret location.
Enter, Ctrl-M, Ctrl-J
Insert CR/LF at the caret location and begin a new line.
TAB, or Ctrl+I
Insert a Tab (HT) character at the caret location. CryptPad steals Ctrl+I from the Textbox for the Initial Capital shortcut, if there is a current selection.

CryptPad Keyboard Shortcuts

This is an alphabetical list of the CryptPad function keys and keyboard shortcuts. The shortcuts shared with the TextBox are marked with an asterisk "*".
Ctrl+A
Edit, Select All
* Ctrl+C
Edit, Copy
Ctrl+F
Edit, Find
Ctrl+F1
Help, Online Contents
Ctrl+G
Edit, Go To
Ctrl+H
Edit, Replace
Ctrl+I
Edit, Initial Capital
Ctrl+L
Edit, Lowercase
Ctrl+N
File, New
Ctrl+O
File, Open
Ctrl+Q
Tools, QuickCrypt
Ctrl+S
File, Save
Ctrl+T
Edit, Transpose
Ctrl+U
Edit, Uppercase
* Ctrl+V
Edit, Paste
* Ctrl+X
Edit, Cut
* Ctrl+Z
Edit, Undo
F1
Help, Local Contents
F3
Edit, Find Next
F5
Edit, Date/Time
F6
Tools, Password
Shift-F3
Edit, Find Previous

Command Line Automation

The CryptPad program supports Command Line Automation. Commands may be placed on a command line call to automate certain editor functions. Processing numerous files by command line will be slower than you might expect because every time you start CryptPad the entire GUI will still open. This process will flash the GUI for each command line call, which will take about a second per call.

If the CryptPad program is started without any command line argument, the current directory is set to the Documents directory, which with Windows 7 is typically "C:\Users\%USERNAME%\Documents". Otherwise, the current directory is set to the directory of the command line argument. This is important for relative file references such as in a SCRIPT file. It also affects the default directory shown with an Open or Save As command dialog. The Open and Save As command always change the current directory to that of the curently open file.

A single command line argument is typically a file name to edit. This allows a file to be selected for editing from the command line. A command line call is how "Open With" is supported.

There is a special mode of operation from the command line for files with an extension of .CryptPad such as "script.CryptPad". These are read as SCRIPT files for command line automation. An optional second command line argument specifies a file to edit using the script automation. This allows the same script to be used on multiple files without editing in the file name. There is no special meaning when a file with an extension of .CryptPad is used with the Open command.

CryptPad supports only one document file being specified on the command line for editing or with a script. If there is more than one command line argument (or two with a .CryptPad script file as the first argument), then the first argument must be "DO". Uppercase is not required for any automation argument. The second argument specifies the function to perform. Additional arguments specify additional information for the specific automation function to perform. The program exits immediately after most automation functions are performed. The file will be saved, if it has actually been changed.

Example command lines assuming .SAFE and .CryptPad are identified in the registry for "Open With":

file.safe
script.CryptPad
script.CryptPad file.safe

Example script.CryptPad file:

do replace "first value" "first string"
do replace "second value" "second string"

The standard "Open With" association does not allow an argument for the .CryptPad file. The CryptPadAdd.REG file provided in the CryptPad project contains the proper registry entries.

CryptPad will return an errorlevel of 0 for a successfully edited file. A value of 1 indicates that no file was saved or changed. An errorlevel of 2 indicates a command line error. Command line errors will also display an error and halt execution until the error is acknowledged. A command line or automation script error will abort saving any changes to the current file.

The following is an example Windows 7 tested CMD script which changes all files in the current directory to UTF-8 assuming the CryptPad program is in a CryptPad subdirectory of the Document directory. The CMD script displays a count of the files found and actually changed:

@echo off
rem
rem CryptPadx.cmd - Automation test
rem

set p=%userprofile%\Documents\CryptPad\CryptPad.exe
set /a total=0
set /a count=0

for %%f in (atest*.txt) do call :change %%f

echo Total: %total% Changed: %count%
pause

goto :EOF

:change

echo Checking %1

set /a total=total+1

%p% do utf-8 %1

echo Change error %errorlevel%

if not errorlevel 1 goto :EOF

set /a count=count+1

goto :EOF

This is an alternate example that depends on the .CryptPad association provided by the file. This method does not need to know the location of the CryptPad.exe file because it is embeddded in the registry.

@echo off
rem
rem CryptPadx.cmd - Automation test
rem

echo do utf-8 >script.CryptPad

set /a total=0
set /a count=0

for %%f in (atest*.txt) do call :change %%f

echo Total: %total% Changed: %count%
pause

goto :EOF

:change

echo Checking %1

set /a total=total+1

script.CryptPad %1

echo Change error %errorlevel%

if not errorlevel 1 goto :EOF

set /a count=count+1

goto :EOF

There is a Command Line function from the menu of the CryptPad program to display the command line arguments provided at program startup. This is useful in debugging Command Line Automation functions.

DO SCRIPT filename

Read automation script commands from a (non-ANSI!) file. This is primarily useful to allow multiple automated replace commands. All automation script commands in the file begin with "DO". The SCRIPT command may not be used (nested) in an automation script. This command may only be used directly from the command line. It is easier to use a special "Open With" association for the .CryptPad extension as described in the CryptPadAdd.REG file.

Example script file:

do edit test.txt
do replace "first value" "first string"
do replace "second value" "second string"

Any error will abort the automation script and return errorlevel 2.

DO ANSI [filename]

Open the specified filename or use the existing open file. Perform the Force ANSI function. If the encoding is already ANSI, the file and its modification date will not be changed. When given as a command line, save the file, and exit. Otherwise, leave open for additional automation script processing.

Remember that a file with only ASCII characters is "UTF-8 (ASCII)" encoded. It will be saved and its modification date will be changed but the file contents will not be changed.

DO UTF-8 [filename]

Open the specified filename or use the existing open file. Perform the Force UTF-8 (ASCII) function. If the encoding is already UTF-8 (ASCII), the file and its modification date will not be changed. When given as a command line, save the file, and exit. Otherwise, leave open for additional automation script processing.

Remember that a file with only ASCII characters is already "UTF-8 (ASCII)" encoded.

DO READONLY file

Open the specified file read-only but do not exit and allow viewing. This allows editing read-only from the Windows Explorer context menu. The registry example file illustrates how to implement this function. This function is designed only for the command line and will abort an automation script.

DO EDIT file

Open the specified file. Any previously opened file will be closed and saved. This command is intended primarily for use in an automation script but will also open a file from the command line. This is the only way to open a .CryptPad file for editing from the command line. A .CryptPad file can also be opened for editing using the File, Open menu option from within the CryptPad program.

DO REPLACE search-string replace-string

This command performs an automated string replace all (ignore case) function in the currently opened file. This command is only for use in an automation script.

Example:

DO EDIT test.txt
DO REPLACE "testing" "implemented"

When a quote is part of the string it is preceded with a backslash. This function supports a subset of C-type escape character processing as described in the Replace function.

Warning! Attempting to create a quote from a command line using an echo command to embed in an automation script does not work. In this case you may use "\q" to indicate a quote.

DO REPLACEMATCH search-string replace-string

This command is similar to DO REPLACE but performs an automated string replace all (match case) function in the currently opened file. This command is only for use in an automation script.

DO REGEX search-string replace-string

This command is similar to DO REPLACE but performs an automated string replace all (ignore case) function using Regular Expression Synatx in the currently opened file. This command is only for use in an automation script.

DO REGEXMATCH search-string replace-string

This command is similar to DO REGEX but performs an automated string replace all (match case) function in the currently opened file. This command is only for use in an automation script.

Menu Bar Functions

The menu bar contains the menu groupings for all the functions performed by the CryptPad program.

File Menu

The file menu contains the typical functions for handling file operations, encoding, encryption, and exiting the program.

New

A new blank and untitled document is created with this option.

If the current document has been modified, you will be offered the option to save the document.

When the window is closed, if you have made any changes, you will be offered the option to save the document to a file.

The new document will be unencrypted. You can immediately set an encryption string to encrypt the document when it is saved. You may refer to the section on Encryption for additional details.

The default encoding for the new document will be UTF-8 (ASCII). You may refer to the section on Encoding for additional details.

Open

Open an existing file for editing. A standard dialog is displayed to select a document file to open.

If the current document has been modified, you will be offered the option to save the document. Unlike Notepad, the document is closed immediately unless you cancel the option to save. You will not return to the document, if you cancel the Open. The encryption string of the current document is preserved for possible use in the document being opened.

If the file is encrypted with an encryption string different from the current encryption string, the encryption string will be requested. If the file is not encrypted, the current encryption string is erased.

You may refer to the section on Encryption for additional details.

CryptPad automatically detects the default ANSI code page, UTF-8, and Unicode file encodings on open. The program assumes UTF-8 encoding unless ANSI characters are detected, which UTF-8 does not read properly. It is unlikely (but possible) ANSI characters will be mistaken as UTF-8. UTF-8 without the Byte Order Mark (BOM) is identical to ASCII unless there are ANSI or Unicode characters.

You may refer to the section on Encoding for additional details.

Unlike Notepad, CryptPad maintains the file in an opened state locked against parallel changes but shared with file readers. This protects the file against accidental parallel modification data loss problems. I have had this happen to me on occasion with Notepad. You can still lose data but it will have to be by deliberate actions and not by a simple accident.

CryptPad offers to attempt to open a file read-only when any file error occurs on open. You may also specify opening read-only with the file type selection on the file open dialog. A read-only file cannot be modified and saved to protect against accidental parallel modification data loss problems. CryptPad will not ever save the file unless you use the "Save As" command.

The CryptPad program displays a warning if the file is greater than about 2MB and requires confirmation to open. The reason for the warning is that it will be very slow to edit a file greater than such a large size. Truly large files may crash the program because it reads the entire file into memory.

The CryptPad program displays a warning if a dangling CR or LF is seen outside of a CR/LF pair with a recommendation to Force CR/LF.

The CryptPad program displays a warning if there are other non-printing ASCII/ANSI control characters (ANSI Blanks) found in the file. This also usually indicates a binary file that you really should not edit.

The CryptPad program displays a warning if NUL characters are found in the file because these must be changed to space characters for the TextBox to work. This usually indicates a binary file that you really should not edit.

Just like Notepad, a space will be substituted for any NUL characters in the file. This is required for the TextBox function. This change will not be noted as a file change to trigger a save reminder but will be included if the file is saved. This change will corrupt any binary file you may happen to save after viewing with CryptPad.

CryptPad will refuse to open a file with a backup extension of 1, 2, or 3. These will need to be renamed, if you wish to edit them.

Save

The current document is saved. If there is a current encryption string, the file is encrypted.

You may refer to the section on Encryption for additional details.

CryptPad uses the original file encoding when saving the file as used when the file was opened or last saved. The file contains a BOM for Unicode. UTF-8 only contains a BOM, if one was originally specified.

You may refer to the section on Encoding for additional details.

The file remains open for continued editing. You must select the "NEW" option to close the file.

Save As

A dialog is displayed to specify a document file name to save the current document. If there is a current encryption string, the file is encrypted. The default file extension is .SAFE for encrypted text files and .TXT for all other text files.

You may refer to the section on Encryption for additional details.

CryptPad defaults to the original file encoding when saving the file. The "Save as type:" option can be used to select alternate file encodings.

You may refer to the section on Encoding for additional details.

The file remains open for continued editing. You must select the "NEW" option to close the file.

Force ANSI

Use this function to force ASCII/ANSI encoding for the current open file, if you must be certain to force ASCII/ANSI encoding when the file is written. This does not change any text currently being edited. CryptPad does not force only ASCII/ANSI text to be entered but an error will occur when the file is saved, if the text contains any Unicode characters which cannot be mapped into the current code page.

Force UTF-8 (ASCII)

Use this function to force "UTF-8 (ASCII)" encoding for the current open file, if you must be certain to force "UTF-8 (ASCII)" encoding when the file is written. This does not change any text currently being edited.

Remember that a file with only ASCII characters is already "UTF-8 (ASCII)" encoded.

You may refer to the section on Encoding for additional details.

Encryption

A dialog is displayed to add, change, or remove the encryption string. The encryption string must be at least 4 ASCII characters. Longer is better. There is no particular maximum limit. About 32 characters is an ideal choice. Only ASCII characters are allowed in the encryption string.

Warning! You will not be able to decrypt the contents of this file, unless you remember this encryption string. If you forget this encryption string, you will not ever be able to retrieve the encryption string. There is absolutely NO back door. Once you click the Ok button, you cannot remove or change the encryption string, unless you remember this string and enter it again.

You will be required to enter a new encryption string twice to verify its contents. This is necessary because you will not be able to see the contents of the encryption string as you type it. If you type the same thing twice, it is assumed there was no error and you will remember the encryption string. Make it something you will certainly remember. Since this is so highly critical, there are no particular requirements for the encryption string contents.

Only ASCII is supported in the encryption functions. Non-ASCII characters will not be encrypted. My apologies to those whose language is not based on ASCII. The encryption algorithm is not particularly sophisticated but it is completely effective to block the curious and prying. This is not intended to be a CIA high security solution!

Almost nobody will be able to break an encryption string of even a single word. A highly safe and effective encryption string is a short sentence or phrase containing at least three words. Using silly words not found in the dictionary is very effective. Remember! You must not forget the encryption string or you will not ever be able to decrypt your hidden data.

See QuickCrypt for additional information about encrypted data.

Exit

This option exits the program.

If the current document has been modified, you will be offered the option to save the document.

Edit Menu

The Edit Menu selection contains functions for special editing of the document.

Undo

Undo the latest editing operation, if an undo is supported for the last operation. Any text you enter can be undone, restoring any optional selected text you replaced, until you use the arrow keys or the mouse to move the caret and enter new text. Only one Undo is supported by the TextBox control. A second Undo will restore the original data.

Cut

Copy the currently selected text to the system clipboard and delete it from the document. If there is no selected text, the system clipboard and the document will be unchanged. You can Undo this operation but the system clipboard continues to retain a copy of the Cut text.

The text remains in the system clipboard no matter how many times you Paste until the next Cut or Copy. The system clipboard is not ever cleared, even when the CryptPad program exits.

Copy

Copy the currently selected text to the system clipboard. If there is no selected text, the system clipboard will be unchanged.

The text remains in the system clipboard no matter how many times you Paste until the next Cut or Copy. The system clipboard is not ever cleared, even when the CryptPad program exits.

Paste

Paste the system clipboard text to the document. This will replace any current selection. You can Undo this operation.

The text remains in the system clipboard no matter how many times you Paste until the next Cut or Copy. The system clipboard is not even cleared when the CryptPad program exits.

Delete

Delete the currently selected text. If no text is selected, the character after the caret position is deleted. You can Undo this operation.

Uppercase

Convert the currently selected text to uppercase. You can Undo this operation.

Lowercase

Convert the currently selected text to lowercase. You can Undo this operation.

Initial Capital

Convert the currently selected text to initial capital on the words preceded by a space. The first character of the selection is assumed to start a word. You may Double-Click on a word and type the shortcut Ctrl+I. You can Undo this operation.

Transpose

The "Transpose" function switches the character to the left and right of the caret. I don't know how often you have a problem with transposing characters as you type but it happens to me a lot. You can Undo this operation.

This function will do nothing if there is currently selected text. Nothing is done when the caret is at the beginning or end of a line. I only do the transpose for ASCII characters because of possible confusion about recognizing and parsing ANSI or Unicode characters.

Find

Display a dialog to specify a string to search.

This function supports a subset of C-type escape character processing for the ASCII control characters commonly found in text files. The new escape characters are described in the Replace function.

There is a RegEx checkbox to select using the search string with Regular Expression Synatx.

Find Next

Find the next string in the document. If no find string has been previously specified, the dialog will be displayed. Unlike Notepad, this function will always search down.

Find Previous

Find the previous string in the document. If no find string has been previously specified, the dialog will be displayed. This function will always search up.

Replace

Display a dialog to specify string search and replacement options.

Escape Characters

This function supports a subset of C-type escape character processing for the ASCII control characters commonly found in text files.

  • \n New line (LF)
  • \r Carriage return (CR)
  • \t Horizontal tab (HT)
  • \\ Backslash

If you use a single backslash in the TextBox, it will be treated like a backslash, if it is not followed by one of the special characters. If you try to enter a search for two backslashes, it will be changed to one unless you enter four!

The context menu and shortcuts in both the find and replace input TextBox also support the new escape characters for the Paste, Copy, and Cut functions.

Regular Expression Syntax

There is a RegEx checkbox to select using the search string and replace strings with Regular Expression syntax. This is described in detail in the Microsoft .NET Framework Regular Expressions documentation. The Multiline mode option is automatically included.

This function is very complex and fully described in the MSDN documentation but I will supply a simple example. The find:

\r([^\n])

will locate a CR not followed by LF and the replace:

\\r$1

will change the CR to "\r". The following character will get dragged into the selection since it is inspected to make sure it is not LF.

Regular Expression syntax already supports the escape characters in the find string but CryptPad adds them to the replace string.

This example "Alternation Construct" uses "Conditional Matching with an Expression" to find lines that do not contain the word cat.

(?(^.*cat.*$)$|^.*$)

Be careful about the '$' in the search string for a replace as described in the MSDN documentation. For example, if you try to remove all lines that contain "cat", this will leave a dangling LF.

^.*cat.*$

Instead you can use this search string to correctly delete the line.

^.*cat.*\r\n

Restore Caret Position

The "Replace All" button on the "Replace" dialog has a special function not found in Notepad. Notepad will change the caret position to the top of the document after a "Replace All" and you will lose track of where you were editing. CryptPad remembers the current caret position line and column. CryptPad attempts to restore the caret position after the "Replace All". CryptPad even attempts to scroll the window to the same location. The caret position restore is not accurate when the "Replace All" changes the number of lines before the caret position or the number of characters on the line before the caret position.

Go To

Displays the line number at the current caret position and allows you to specify a new line to change the current caret position. When Word Wrap is on the line number is of the wrapped lines, therefore it may not be the same line as when Word Wrap is off.

When you are entering a line number provided by a program, you will usually need to make sure that Word Wrap is off or you will go to the wrong line.

Select All

Select all the text in the document. The text is not copied to the clipboard until you specify a Copy.

Date/Time

Insert the date and the time in ISO 8601 standard universal date and time formats. The time includes milliseconds. The local time is used but the time zone is not indicated. These are separate date and time fields so they are separated with a space, as allowed by the standard. This is not to be confused with the standard format for combined date and time which is separated by a "T" character.

Example:

2013-03-24 15:55:58.347

If there is currently selected text, it will be replaced. It is assumed the selected text is an old date and time value. You can Undo this operation.

Tools Menu

The Tools Menu contains some additional special options added by the CryptPad program.

Password

Insert an automatically generated random password into the document. The randomization selects 16 characters from uppercase/lowercase ASCII letters and numbers. This is particularly useful in an encrypted file for remembering unique, ultra-secret, highly secure passwords for websites. Do not use this as an encryption string! It will be impossible to remember.

Example:

EHbKLQZRRv53VN5K

If there is currently selected text, it will be replaced. It is assumed the selected text is an old password. You can Undo this operation.

When you use the random password generation for websites, the sophisticated password would be stored in an encrypted file so you don't have to remember it. A typical line or sequence of lines in the encrypted file would have the website address, the email address/username, and the password. This can be used for a quick and simple copy/paste of the website address, then copy/paste the login username, and finally copy/paste the password. Unfortunately, I have discovered some difficult websites will not allow you to copy and paste the password. This is a poor security measure because you may want to paste a password you can't possibly remember or don't want to type. It is easy to delay multiple pastes to restrict password hacking.

QuickCrypt

Using the current encryption string, convert the plaintext to the encrypted text. If there is not an encryption string present, one will be requested. This function is particularly useful to copy and paste encrypted text to and from email or instant messages.

You can recognize encrypted text because it always begins with the encryption prefix "~!@#$". If the encrypted text is already shown, this command will convert the encrypted text to the plaintext.

The version 1 encryption prefix was "~!@#". If you need to know, just remove character 5 ('$') and 6-13 (hexadecimal checksum) to restore version 1 compatibility.

Warning! If you change anything else while the encrypted text is shown, you will not be able to decrypt the text.

The encryption prefix "~!@#$" must be the first characters in the text to reverse the encryption. Version 2 has an eight hexadecimal character checksum after the encryption prefix to verify the data has not been modified or corrupted. There is also another eight hexadecimal character checksum which verifies that the current encryption string actually applies to this text.

If any encryption text is changed, in any editor, you lose the ability to ever decrypt the text. Someone can destroy your encrypted data but they can never see it.

You may refer to the section on Encryption for additional details.

Find next non-ASCII

Find and select the next non-ASCII character after the caret or current selection.

Find longest line

Find the longest line and place the caret at the end of the line. This function ignores Word Wrap.

Find next ANSI Blank

The first non-printing ASCII/ANSI character found in the file will be changed to the string "\xnn" and selected. "nn" will be the hexadecimal value of the character. Values will always be "\x01", "\x1c", "\x1d", "\x1e", "\x1f", "\x81", "\x8d", "\x8f", "\x90", "\x9d", or "\xa0". These values represent characters which do not display anything so they are invisible in the typical fonts. Some of these characters display as a space and some are zero width and do not display at all.

The "\xa0" character is a No-Break Space. In an HTML file this is created with "&nbsp;". If you need this in a text file it can be entered with the Alt+0160 keystroke sequence.

Force CR/LF (Windows)

First change all CR/LF to LF, change all remaining CR to LF, then make sure every LF is CR/LF. This is the normal condition for a data file used by the Windows operating systems. This is the normal editing condition.

Force LF (UNIX)

First change all CR/LF to LF, then change all remaining CR to LF. This is the normal condition for a data file used by UNIX type operating systems. This is not a normal editing condition. This condition is usually only created before a close and save. Some CryptPad and TextBox display and editing functions will not work correctly on a Unix file.

Mark dangling CR or LF

The first dangling CR or LF found in the file will be changed to the string "\r" or "\n" and selected. There will be no dangling CR or LF in a normal file. There will also be none if you responded "OK" to the warning prompt when the file is opened or after using the "Force CR/LF" tool.

Hard Wrap

Set line width permanently to the current window width by inserting CR/LF. This function does nothing unless Word Wrap is enabled. A space is left at the end of the line for possible Unwrap or Trim. It is not possible to find the end of a wrapped line with a simple replace.

When you compose paragraphs using CryptPad, Notepad, or any editor, it is helpful to have lines limited to a short width (about 60 characters) suitable for reading. Newspaper columns illustrate a very narrow width. A typical book will have a column width of about five to six inches.

When Word Wrap is on the line width will automatically adapt to the window size while removing and adding content. The Hard Wrap function is useful to change long lines with Word Wrap used while composing to short lines suitable for pasting, such as in email.

Unwrap

Unwrap lines by removing CR/LF preceded by a space. These dangling spaces are normally created by Hard Wrap. After you use the Trim Tool, Unwrap will no longer work. This allows composing to continue removing and adding content while automatically adjusting to the window width.

This is simply a predefined replace of " \r\n" with " ".

Trim

Trim any space at the beginning or end of a line. It is a tidy practice to make sure there are are no extra spaces. It is assumed that Tab, not Space, is used for indent. You may or may not choose to use Trim after a Hard Wrap. If you do, you will not be able to Unwrap.

This is simply a predefined replace of " \r\n" with "\r\n" and "\r\n " with "\r\n" .

Command Line

Display the current directory and the command line arguments provided at program startup. This is particularly useful to understand the environment of Command Line Automation functions. CLA errors will automatically display this information.

Automatic Backup

This menu selection allow you to select options for automatic backup. You can select anything from zero to 3 backups. When a backup is performed file.ext is renamed to file.ext.1, file.ext.1 is renamed to file.ext.2, and so on for the number of backups selected.

Backup only occurs with the first save after open. I have the practice of editing HTML in a tiled window with Internet Explorer (IE) displaying the HTML. I save the file many times while editing and refresh the IE window to see the results. I do not want a backup for every intermediate save. If you want to force a backup while editing, then you will need to open the file again.

CryptPad will refuse to open a file with a backup extension of 1, 2, or 3. These will need to be renamed, if you wish to edit them.

Format Menu

These options change the format of how the text is displayed in the CryptPad TextBox.

Word Wrap

Toggle word wrap. A TextBox line longer than 1024 is always wrapped to a second display line breaking even in the middle of a word.

When Word Wrap is on, the TextBox lines will be wrapped at the width of the current window. The rules for automatic wrapping of a TextBox window are complicated. Generally, wrapping occurs at a "word" boundary.

Font

Displays a font dialog to select the font to use in displaying and editing the document. Lucida Console 12pt is the original setting.

Font Color

Displays a color dialog to select the font color to use in displaying and editing the document. Black is the original setting.

Background Color

Displays a color dialog to pick a different background color for the TextBox during editing. White is the original setting.

View Menu

This menu allows you to select what information you wish to see in the Status Bar. If none of the items are selected, the Status Bar will not be shown. If the window is not wide enough for everything to display, then only the first items that fit will display.

Line/Char

Toggle the display in the Status Bar of the current line number and character position of the caret in the current line. This is not necessarily the same as the column number, if there are tabs in the line. The line number can be different depending on whether Word Wrap is on or not.

Before/After

Toggle the display in the Status Bar of the number of characters before the caret and the number of characters after the caret.

Lines/Chars

Toggle the display in the Status Bar of the total number of lines and the total number of characters in the file.

Beware! The current line number is for wrapped lines in Word Wrap mode but the total number of lines is still for real lines. Also note that the total number of characters includes the CR/LF characters and any other control characters in the text. The total number of characters will only match the file size for files with ANSI encoding or UTF-8, which contains only ASCII characters.

Encoding

Toggle the display in the Status Bar of the file encoding. Typical file encodings:
  • "Windows-1252"

    Also known as "ANSI", "ISO-8859-1", and "Western European (Windows)". This is typical for many computer systems. This encoding is for the local code page which can be different on your computer depending on how the computer system is configured. ANSI characters are always 8 bits.

    You will not normally see this encoding in CryptPad unless you are opening a file which contains ANSI characters or you have specified for a file to be saved with ANSI encoding.

  • "UTF-8 (ASCII)"

    This encoding does not use a Byte Order Mark (BOM) at the beginning of the file. This is the recommended encoding for all current files. UTF-8 characters use 8 bits but non-ASCII characters are always followed by additional 8 bit characters.

    CryptPad will normally open a file with this encoding. This encoding is completely appropriate for files containing only ASCII characters and will not cause a problem creating ASCII text for any program expecting ASCII characters. This encoding will also allow you to enter Unicode characters, which will cause problems for some older programs, which expect only ASCII or ANSI.

    UTF-8 characters can be mistaken for ANSI characters by an older program looking for ANSI characters. A person looking at the file contents in an editor can usually recognize immediately that the character patterns do not make sense. ANSI characters can not usually be mistaken for UTF-8 characters by a newer program looking for UTF-8 characters. UTF-8 characters follow a certain pattern.

  • "Unicode (UTF-8)"

    This is the same as UTF-8 (ASCII) encoding but it uses a BOM. This encoding is not appropriate for programs requiring ASCII files, even if the file contains only ASCII characters because the BOM writes non-ASCII characters to the beginning of the file. Most current programs and editors such as Notepad and CryptPad use this encoding with no problems but older programs may fail in mysterious ways.

  • "Unicode"

    Also known as "UTF-16". All characters in this encoding use 16 bits. This encoding is rarely used by files for Windows programs. It is important for programmers to note that most Windows programs use this format internally for all characters.

  • "Unicode (Big-Endian)"

    This encoding is normally only used on non-Windows computers.

Help Menu

The Help Menu contains options for viewing help and program information.

Online Contents

This option will open the web site "http://www.frank-t-clark.com/Professional/Papers/CryptPad/CryptPad.html" which contains the online version of the documentation for the current version of the program. This may not match the version you are using. The website is often updated with additional documentation and versions.

This web page may be saved to the "CryptPad.html" file in the directory with the program. This updates the Local Contents. Links from the page may fail unless additional pages and images are copied to the directory from the website. You will not be able to save the file if the program is installed in the "Program Files" directory unless you have administrator privilege.

Local Contents

This option will open the local web file "CryptPad.html" which contains the local version of the documentation for the program. The file is expected to be in the same directory as the program file. Links from the page may fail unless additional pages and images are copied to the directory from the website.

This is useful for when you are not connected to the Internet. This help file and the minimum graphic file are included in the download zip file.

About

This option displays the program version number and other information.


Revised 2014-06-01