<p>Once key initialization has been performed this property is set to true, otherwise it is set to false. Calling <ahref="#Burn">Burn</a> will immediately set this to false.
<p>Every algorithm I implement gets given a unique ID number so that if I use several different algorithms within a program I can determine which one was used. This is a purely arbitrary numbering system.
<p>This is the maximum size of key you can pass to the cipher (in bits!).
<p><fontsize="+1"><aname="SelfTest">class function SelfTest: boolean;</a></font>
<p>In order to test whether the implementations have all been compiled correctly you can call the SelfTest function. This compares the results of several encryption/decryption operations with known results for the algorithms (so called test vectors). If all the tests are passed then true is returned. If ANY of the tests are failed then false is returned. You may want to run this function for all the components when you first install the DCPcrypt package and again if you modify any of the source files, you don't need to run this everytime your program is run. Note: this only performs a selection of tests, it is not exhaustive.
<p>This procedure initializes the cipher with the keying material supplied in Key. The Size of the keying material is specified in <b>BITS</b>. The InitVector is a pointer to chaining information (only used for block ciphers). The variable that this points to should be equal to the block size of the algorithm. If <em>nil</em> is specified then (if necessary) an initialization vector is automatically generated from the key. Note: the method for generating automatic IVs is different from DCPcrypt v1.31, if this is a problem uncomment the DCPcrypt v1.31 compatibility mode line in DCPcrypt2.pas.
<p>Init example: use the hash of a string to initialize the cipher
<p>This procedure initializes the cipher with a hash of the key string using the specified hash type (in a way similar to the example above). To replicate the behaviour from DCPcrypt v2 Beta 1 use Cipher.InitStr(KeyStr,TDCP_sha1).
<p>InitStr example: prompt the user for a passphrase to initialize the cipher
<p>Once you have finished encrypting/decrypting all your data call Burn to erase all keying information. This is automatically called once the cipher is freed, however it is a good habit to call this procedure explicitly.
<p>Stream ciphers (and block ciphers in chaining modes) generally store chaining information that is dependant on the information already encrypted. Consequently decrypting a block of information immediately after encrypting it won't result in the original information because when you called the decrypt procedure the chaining information was different from when you called the encrypt procedure. Hence use Reset to restore the chaining information to it's original state.
<p>Remember that calling <ahref="#EncryptString">EncryptString</a>, <ahref="#DecryptString">DecryptString</a>, <ahref="#EncryptStream">EncryptStream</a> and <ahref="#DecryptStream">DecryptStream</a> will also affect the chaining information.
Cipher.Decrypt(Data,Data,Sizeof(Data)); <em>// now decrypt it</em>
Cipher.Burn; <em>// clear keying information</em>
Cipher.Free;
Result:= CompareMem(@InData,@Data,Sizeof(Data)); <em>// compare input and output</em>
<b>end</b>;
</pre>
The above <em>should</em> always return true.
<p><fontsize="+1"><aname="Encrypt">procedure Encrypt(const Indata; var Outdata; Size: longword);</a></font>
<p>Encrypt Size bytes from Indata and place it in Outdata. Block ciphers encrypt the data using the method specified by the <ahref="BlockCiphers.html#CipherMode">CipherMode</a> property. Also see the notes on <ahref="#Reset">Reset</a>.
<p><fontsize="+1"><aname="Decrypt">procedure Decrypt(const Indata; var Outdata; Size: longword);</a></font>
<p>Decrypt Size bytes from Indata and place it in Outdata. Block ciphers decrypt the data using the method specified by the <ahref="BlockCiphers.html#CipherMode">CipherMode</a> property. Also see the notes on <ahref="#Reset">Reset</a>.
<p>Encrypt Size bytes from the InStream and place it in the OutStream, returns the number of bytes read from the InStream. Encryption is done by calling the <ahref="#Encrypt">Encrypt</a> procedure. Also see the notes on <ahref="#Reset">Reset</a>.
<p>Decrypt Size bytes from the InStream and place it in the OutStream, returns the number of bytes read from the InStream. Decryption is done by calling the <ahref="#Decrypt">Decrypt</a> procedure. Also see the notes on <ahref="#Reset">Reset</a>.
<p>Encrypt the string Str then Base64 encode it and return the result. For stream ciphers the <ahref="#Encrypt">Encrypt</a> procedure is called to do the encryption, for block ciphers the <ahref="BlockCiphers.html#EncryptCFB8bit">CFB8bit</a> method is always used. Base64 encoding is used to ensure that the output string doesn't contain non-printing characters.
<p>Base64 decode the string then decrypt it and return the result. For stream ciphers the <ahref="#Decrypt">Decrypt</a> procedure is called to do the decryption, for block ciphers the <ahref="BlockCiphers.html#DecryptCFB8bit">CFB8bit</a> method is always used.
<p>This example shows how you can encrypt the contents of a file, takes the input and output file names from two edit boxes: boxInputFile and boxOutputFile.