blowfish.writer-encrypt

function

Library: Blowfish (OMFFBLOWFISH)
Import : omffblowfish.xmd

Returns: A writable output target for streaming data.


Declaration
export string sink function
   writer-encrypt     into value string sink output-data
                  with-key value string      encryption-key


Purpose

Use blowfish.writer-encrypt to write encrypted data to its value string sink output-data argument, encrypted using its encryption-key argument. The decrypted data (that is, the clear text) is written to the string sink returned by the blowfish.writer-encrypt function call.

Note that the Blowfish algorithm processes data in 64-bit chunks. If the length of the input is not a multiple of 64 bits, it will be padded with null bytes. Similarly, the length of the data written to output-data by blowfish.writer-encrypt will be a multiple of 64 bits, and may therefore be null padded.

Example

The following example uses blowfish.writer-encrypt to encrypt a clear text, then passes the result on to the string sink function hexadecimal-dump () for further processing.

  import "omffblowfish.xmd" prefixed by blowfish.
  
  define string sink function
     hexadecimal-dump (value string sink s)
  as
     using group "generate hexadecimal dump"
        using output as s
           submit #current-input
  
  process
     local string clear-text initial { "Hello, World!" }
  
     using output as hexadecimal-dump (#main-output)
        using output as blowfish.writer-encrypt into #current-output with-key "TESTKEY"
           output clear-text
  
  group "generate hexadecimal dump"
     find any => c
        output "2fz16rd" % binary c || " "

Usage Note

To use blowfish.writer-decrypt, you must import OMFFBLOWFISH into your program using an import declaration such as:

  import "omffblowfish.xmd" prefixed by blowfish.