Artifact 9e652f0f7f1f56f7c6a7fd21f68da1a67cf02309b5df0a17d92402b1c7f24577:
- Executable file
r37/lisp/csl/jlisp/LispDigester.java
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1477) [annotate] [blame] [check-ins using] [more...]
// // This file is part of the Jlisp implementation of Standard Lisp // Copyright \u00a9 (C) Codemist Ltd, 1998-2000. // import java.io.*; import java.security.*; class LispDigester extends LispStream { LispDigester() { super("<md5 digester>"); try { md = MessageDigest.getInstance("MD5", "SUN"); } catch (NoSuchAlgorithmException e) { Jlisp.errprintln("No MD5 available: " + e.getMessage()); md = null; } catch (NoSuchProviderException e) { Jlisp.errprintln("No provider: " + e.getMessage()); md = null; } } void flush() { } void close() { md = null; } void print(String s) { if (md == null) return; char [] v = s.toCharArray(); // It *MAY* be better to use getChars here and move data into a pre-allocated // array of characters. for (int i=0; i<v.length; i++) { char c = v[i]; // characters are in general 16-bits wide (even though all the charcters that // I will normally use in the UK are only 7 bits) so I pass them to the // message digest process as two bytes each. md.update((byte)(c >> 8)); md.update((byte)c); } } void println(String s) { print(s); if (md != null) { md.update((byte)0); md.update((byte)'\n'); } } } // end of LispDigester.java