table top left corner

CapeSoft CryptoNite Class Reference

table top right corner
table left side

 

table top left corner   table top right corner
table left side

 

Version: version number
CapeSoft Software copyright

 

table right side
table bottom left corner table bottom table bottom right corner


table top left corner Introduction table top right corner
table left side

CryptoNite

CryptoNite provides encryption and decryption in your applications for security, safe data transfer etc. Cryptonite completely removes the complexity of implementing cryptography. Cryptonite aims to make using encryption as simple as possible, and handles all the complexity for you. CryptoNite requires CryptoNite.

CryptoNite will easily help you:

  • Encrypt and decrypt strings - with one line of code.
  • Encrypt and decrypt files - with one line of code.
  • Handle a wide variety of encryption types, from Symmetric key cipher such as Blowfish, AES and 3DES to asymmetric public/private key cryptography such as RSA
  • Perform encryption or decryption quickly and simply, with no experience with cryptography
  • Handles certificates
  • Sign and verify signatures using public/private key cryptography
  • Base64 encoding and Decoding using CryptoNite
  • Unicode (UTF-8) to ANSI and ANSI to Unicode using CryptoNite.

Classes

CryptoNite

The main CryptoNite class, handles the primary encryption and decryption tasks, as well as hashing, encoding, loading and saving data etc..

Blowfish

Provides Blowfish encryption and decryption. Blowfish is a symmetric key cipher - the same key (password) is used to encrypt and decrypt the data. The CryptoNite class provides methods for creating a Blowfish object and encrypting and decrypting data. Typically the Blowfish class does not need to be used directly, as CryptoNite provides method that encapsulate this functionality, see the BlowFish Section for more information.

CryptoIni

A replacement class for the standard ABC INI manager. Provides the ability to encrypt and decrypt fields in the file.

CryptoNiteCallback

The CryptoNiteCallback implements the ABC FileCallBackInterface interface to allow on the fly encryption and decryption of fields within tables, regardless of the backend.

Important: Because of a bug in the SoftVelocity SQL driver, version of Clarion prior to C6.3 9057 cannot use the FileCallBackInterface with SQL, as the REGET function will not cause the callback to be fired. This only applies to applications that use the SQL file driver.

 

 

 

table right side
table bottom left corner table bottom table bottom right corner


 

table top left corner CryptoNite table top right corner
table left side

 

box Using the CrytptoNite class

box CryptoNite Method Reference

Coming Soon!  
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

box Blowfish Encryption and Decryption

Important Notes Introduction to use Blowfish Encryption
Example An example of using CryptoNite to encrypt and decrypt data using the Blowfish cipher
   
InitBlowfish Initialise the Blowfish object. Must be called before any of the Blowfish functionality can be used
KillBlowfish Cleans up and diposes all allocated memory
bfEncrypt Encrypt data stored in a StringTheory object using the current key
bfdecrypt Decrypt data stored in a StringTheory object using the current key
bfEncryptString Encrypt a Clarion string
bfDecryptString Decrypt a Clarion string
bfSetKey Set the key to use for encryption and decryption

box CryptoNite Property Reference

Coming Soon  
   
   
   
   

 

table right side
table bottom left corner table bottom table bottom right corner

 

Using the CryptoNite Class

In general a CryptoNite object is declared as simply as

st CryptoNite

Where st is the label name (and can be almost anything.) The length of the string is undefined, and is dynamic. In other words the string will automatically grow, and shrink as required. You do not need to worry about the length.

Values are assigned into the string using the SetValue method, or by loading a file off the disk using the LoadFile method.

st.SetValue('hello world')

st.LoadFile('c:\windows\win.ini')

After that the string can be manipulated in a number of different ways, using the methods described below. For example to Base64 encode the string;

st.Base64Encode()

 

CryptoNite Method Reference

 

 

Blowfish Encryption and Decryption Methods

The CryptoNite class supports BlowFish encryption and decryption of strings and files. This uses the csBlowFish class that is a part of CryptoNite.

Important Notes

  1. The plainText (the data being encrypted) can contain binary data, not just plain text data

  2. The cipherText (encrypted data) is binary data. To store it in ASCII text form call the Base64Encode method convert it to Base64 encoded data.

  3. The cipherText is always the same size as the plainText is (the data size is maintained when encrypting and decrypting, so both forms are the same length). This is not true of Base64 encoding, which increases the data size when performning encoding. The Base64Encode method handles automatically increasing the size of the string when encoding for you.

  4. The data being encryped (or decrypted) must always be a multiple of 8 bytes (characters) long. Future releases will support CBC mode for encrypting strings of arbitrary length and for improved security when encrypting more than 1 block of data (8 bytes) at a time.

 

Encryption and Decryption Examples

An example of encrypting and Base64 encoding a string using the CryptoNite object.

s           CryptoNite
password    string(256)
  code
   
! Initialise the Blowfish object and set the key
    s.InitBlowfish('
j.vnhK/xNf6\$rtYidR\v;o#^bubRL`.vf?/lVa_lawDE^I#XT1!C!n3')

    password = '
My Secret Password String! ! Note: This can be binary data, not just text

   
! Encrypt and Base64 encode a string
    s.SetValue(password)
    s.Encrypt()
    s.Base64Encode()
    password = s.GetValue()  
   ! password now contains encrypted, Base64 encoded data.


   
! Encrypt and Base64 encode a string
    s.SetValue(password,
True)   ! Set the value, allow clipping (only for text or base64 encode strings!)
    s.Base64Decode()
    s.Decrypt()
    password = s.GetValue()     
! password now contains the original value

See the methods below for additional examples.

InitBlowfish Procedure (string key)

Initialises the Blowfish object. This must be called before any of the other Blowfish methods are used.

Parameters

key

The key to use for encryption. This string contains a binary value and can be up to 56 bytes (characters) long (448bit). Typically you should provide a string that is exactly 56 bytes in length.

Return Value

Returns True (1) if succesful and False (0) if encryption fails.

Example

s           CryptoNite
plainText   string(256)   ! unencrypted value
cipherText  string(256)   ! encrypted value
 
code
    s.InitBlowfish('
j.vnhK/xNf6\$rtYidR\v;o#^bubRL`.vf?/lVa_lawDE^I#XT1!C!n3')
    plainText = '
Shhh, it's a secret!'
    s.EncryptString(plainText, cipherText)

 

 

KillBlowfish Procedure ()

Cleans up and deallocates memory. Will be called automatically when the CryptoNite object is destroyed.

 

 

 

bfEncrypt Procedure ()

Encrypts the current value stored in the CryptoNite object. See Important Notes for more information.

 

Return Value

Returns True (1) if succesful and False (0) if encryption fails.

 

 

 

bfDecrypt Procedure ()

Decrypts the current value stored in the CryptoNite object. See Important Notes for more information.

 

Return Value

Returns True (1) if succesful and False (0) if encryption fails.

 

 

 

bfEncryptString Procedure (*string plainText, *string cipherText)

Encrypts the passed plainText string and stores the encrypted data in the passed cipherText string. See Important Notes for more information. The cipherText string should be at least the same length as the plainText string in order to store the encrypted data.

Parameters

plainText

A string to store the decrypted data that results from decrypting the passed cipherText.

cipherText

The data to decrypt

 

Return Value

Returns True (1) if succesful and False (0) if encryption fails.

Example

s           CryptoNite
 
code
    s.InitBlowfish('
j.vnhK/xNf6\$rtYidR\v;o#^bubRL`.vf?/lVa_lawDE^I#XT1!C!n3')
    s.EncryptString(plainText, cipherText)

 

 

 

bfDecryptString Procedure (*string plainText, *string cipherText)

Decrypts the passed cipherText string and stores the decrypted data in the passed plainText string. See Important Notes for more information. The plainText string should be at least the same length as the chipherText string in order to hold the data.

Parameters

plainText

A string to store the decrypted data that results from decrypting the passed cipherText.

cipherText

The data to decrypt

Return Value

Returns True (1) if succesful and False (0) if encryption fails.

 

Example

s           CryptoNite
 
code
    s.InitBlowfish('
j.vnhK/xNf6\$rtYidR\v;o#^bubRL`.vf?/lVa_lawDE^I#XT1!C!n3')
    s.DecryptString(plainText, cipherText)

 

 

 

bfSetKey Procedure (string key)

Sets the key stored by the object for encryption. The key is initially set when the InitBlowfish method is called, however this can be used to change the key being used after the object has been initialised.

Parameters

key

The key to use for encryption. This string contains a binary value and can be up to 56 bytes (characters) long (448bit). Typically you should provide a string that is exactly 56 bytes in length.

 

 

 

CryptoNite Property Reference

 


table right side
table bottom left corner table bottom table bottom right corner



All content © Copyright CapeSoft Software