blowfish.encode

function

Library: Blowfish (OMBLOWFISH)
Import : omblowfish.xmd

Returns: A string encoding of the encrypted data.


Declaration
export external string function
   encode (value string clear-text,
           value state  state)


Purpose

Use blowfish.encode to read clear-text, and encrypt it against state. The encrypted data is returned as a string that can be further processed.

state argument must be initialized with an encryption key; this can be accomplished using blowfish.set-encryption-key.

The input string must be at most eight characters long. If it is any shorter, it is padded with null bytes to a length of eight characters before it is encoded. If it is any longer, an exception is thrown. The returned string is always eight characters long, and may contain null bytes.

Example

The following example uses blowfish.encode to encrypt a sequence of eight bytes.

  import "omblowfish.xmd" prefixed by blowfish.
  
  process
     local blowfish.state state initial { "TESTKEY" }
     local string         s
     local string         t     initial { "%0#" ||* 3 || "%1#" || "%0#" ||* 3 || "%2#" }
  
     set s to blowfish.encode (t, state)

Usage Note

To use blowfish.encode, you must import OMBLOWFISH into your program using an import declaration such as:

  import "omblowfish.xmd" prefixed by blowfish.

Other Library Functions