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 elsewhere


Purpose

Use blowfish.writer-encrypt to write encrypted data to a string sink, its first argument, and using an encryption key, its second argument. The decrypted data (i.e., the clear text) is written to the 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-databy blowfish.writer-encrypt will be a multiple of 64 bits, and may therefore be null padded.

Usage Note

To use blowfish.writer-encrypt, you must import omffblowfish.xmd into your program using a statement like this:

     import "omffblowfish.xmd" prefixed by blowfish.

(Please see the import topic for more on importing.)

Example


     import "omffblowfish.xmd" prefixed by blowfish.
  
  
     define string source function
        hexadecimal-dump value string source s
     as
        using group "generate hexadecimal dump"
           submit s
  
  
     process
        local string clear-text  initial { "Hello, World!" }
        local stream cypher-text
  
        open cypher-text as buffer
        using output as blowfish.writer-encrypt into cypher-text with-key "TESTKEY"
           output clear-text
        close cypher-text
  
        output hexadecimal-dump cypher-text || "%n"
  
  
     group "generate hexadecimal dump"
        find any => c
           output "2fz16rd" % binary c || " "
        

Other Library Functions