item2
Next»

contents

 

Introduction - 1

History - 2

Overview - 3

Advanced features - 4

Work in progress - 5

One possibility - 6

Conclusion - 7

 

References

Appendix 1 - blowfish

Appendix 2 - tkspline

Appendix 1 - blowfish.tcl script

package provide blowfish 0.10
package require critcl

if {![critcl::compiling]} {
   puts stderr "This package cannot be \
                 compiled without critcl enabled"
   exit 1
}

namespace eval blowfish {

   critcl::cheaders blowfish_c/*.h
   critcl::csources blowfish_c/*.c

   critcl::ccode {
      #include "blowfish.h"
   }

   critcl::ccommand blowfish {dummy ip objc objv} {
      int index, dlen, klen, count = 0;
      unsigned char *data, *key;
      Tcl_Obj *obj;
      BF_KEY kbuf;
      unsigned char ivec[] =  
         {0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
      static char* cmds[] = { "encode", "decode", NULL };
      if (objc != 4) {
        Tcl_WrongNumArgs(ip, 1, objv, "mode data key");
        return TCL_ERROR;
      }

      if (Tcl_GetIndexFromObj(ip, objv[1],
              cmds, "option", 0, &index) != TCL_OK)
        return TCL_ERROR;

      obj = objv[2];
      if (Tcl_IsShared(obj))
        obj = Tcl_DuplicateObj(obj);
        data = Tcl_GetByteArrayFromObj(obj, &dlen);
      key = Tcl_GetByteArrayFromObj(objv[3],
      &klen);

      BF_set_key(&kbuf, klen, key);
      BF_cfb64_encrypt(data, data, dlen, &kbuf, ivec, &count,
                index == 0 ? BF_ENCRYPT : BF_DECRYPT);

      Tcl_SetObjResult(ip, obj);
      return TCL_OK;
   }
}

see also

Critcl Home Page

Tclkit Home Page

Starkit Home Page

Wikit Home Page

Tclers' Wiki

Steve's Website

Jean-Claude's Website

Paper by S. Landers & J.C. Wippler, as presented at Tcl/Tk 2002 conference - see also original PDF.

Papers & Presentations