blowfish.writer-decrypt

function

Library: Blowfish (OMFFBLOWFISH)
Import : omffblowfish.xmd

Returns: A writable output target for streaming data.


Declaration
export string sink function
      writer-decrypt     into value string sink output-data
                     with-key value string encryption-key elsewhere
                     trimming-mode value trimming-mode type trimming-mode optional initial {no-trimming}


Purpose

Use blowfish.writer-decrypt to write decrypted data to a string sink, its first argument, and using an encryption key, its second argument. The encrypted data is written to the sink returned by the blowfish.writer-decryptfunction 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-decrypt will be a multiple of 64 bits, and may therefore be null padded.

The optional third argument can be used to specify if the null padding should be removed. The default behavior is not to trim the null bytes. If their trimming is desired, you should specify trimming-mode null-trimming as the third argument

Usage Note

To use blowfish.writer-decrypt, you must import omfblowfish.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
        character-dump value string source s
     as
        using group "generate character dump"
           submit s
  
  
     process
  
        local string cypher-text    initial { "0b 15 cf b6 30 3c 5b bf e8 ad 3b ee 31 ce 59 5f" }
        local string encryption-key initial { "TESTKEY" }
  
  
        using output as blowfish.writer-decrypt into #main-output with-key encryption-key trimming mode null-trimming
           output character-dump cypher-text || %n
  
  
     group "generate character dump"
        find ul["a" to "f" | digit]{2} => n
           output "b" % (n base 16)
  
  
        find white-space+
  
  
        find any => c
           not-reached message "An invalid character (" || c || ") was encountered in a hexadecimal stream."