data type
Library: Blowfish (OMBLOWFISH)
Import : omblowfish.xmd |
The state
opaque data type carries state information between calls to the
functions of the OMBLOWFISH library. A state
also contains information
about the encryption key being used to encrypt or decrypt the data.
Within your program, you can create as many instances of the state
data type as you require. A instance of the state
data type can be
declared as a global
, local
, or even passed as an argument to a
function.
A particular instance of state
must be initialized using
blowfish.set-encryption-key
before being used.
Please refer to Opaque Data Types for a general description of opaque data types and how they are used.
The state
data type is central to the OMBLOWFISH library, and is
used by all of its functions.
blowfish.decode
is an external function that takes a 64-bit quantity and a
state
, and returns the decrypted value as a 64-bit quantity,
encased as a string
.
blowfish.encode
is an external function that takes a 64-bit quantity and a
state
, and returns the encrypted value as a 64-bit quantity,
encased as a string
blowfish.set-encryption-key
takes an encryption key as a string
and a
state
, and initializes the state
using the encryption key.
Once you have declared an instance of blowfish.state
, you must initialize it
using blowfish.set-encryption-key
.
import "omblowfish.xmd" prefixed by blowfish. process local blowfish.state state set-encryption-key ("ENCRYPTION KEY", state)
The OMBLOWFISH library exports a conversion function from string
to
state
that can be used to write this example more concisely:
import "omblowfish.xmd" prefixed by blowfish. process local blowfish.state state initial { "ENCRYPTION KEY" }