Next: , Previous: , Up: Guile API Conventions   [Contents][Index]

3.3 Representation of Binary Data

Many procedures operate on binary data. For instance, pkcs3-import-dh-parameters expects binary data as input.

Binary data is represented on the Scheme side using bytevectors (see Bytevectors in The GNU Guile Reference Manual). Homogeneous vectors such as SRFI-4 u8vectors can also be used1.

As an example, generating and then exporting Diffie-Hellman parameters in the PEM format can be done as follows:

(let* ((dh  (make-dh-parameters 1024))
       (pem (pkcs3-export-dh-parameters dh 
  (call-with-output-file "some-file.pem"
    (lambda (port)
      (uniform-vector-write pem port))))



Historically, SRFI-4 u8vectors are the closest thing to bytevectors that Guile 1.8 and earlier supported.