home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / type1enc.ps < prev    next >
Text File  |  2002-02-22  |  3KB  |  66 lines

  1. %    Copyright (C) 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: type1enc.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  14. % type1enc.ps
  15. % PostScript language versions of the Type 1 encryption/decryption algorithms.
  16.  
  17. % This file is normally not needed with Ghostscript, since Ghostscript
  18. % implements these algorithms in C.  For the specifications, see Chapter 7 of
  19. % "Adobe Type 1 Font Format," ISBN 0-201-57044-0, published by Addison-Wesley.
  20.  
  21. /.type1crypt    % <R> <from> <to> <proc> .type1crypt <R'> <to>
  22.         % (auxiliary procedure)
  23.  { 4 1 roll
  24.    0 2 index length getinterval
  25.    0 1 2 index length 1 sub
  26.     {        % Stack: proc R from to index
  27.       2 index 1 index get            % proc R from to index C/P
  28.       4 index -8 bitshift xor 3 copy put    % proc R from to index P/C
  29.       5 index exec                % proc R from to C
  30.  
  31. %        Compute R' = ((R + C) * 52845 + 22719) mod 65536
  32. %        without exceeding a 31-bit integer magnitude, given that
  33. %        0 <= R <= 65535 and 0 <= C <= 255.
  34.  
  35.       4 -1 roll add
  36.       dup 20077 mul    % 52845 - 32768
  37.       exch 1 and 15 bitshift add    % only care about 16 low-order bits
  38.       22719 add 65535 and 3 1 roll
  39.     }
  40.    for exch pop 3 -1 roll pop
  41.  } bind def
  42.  
  43. % <state> <fromString> <toString> .type1encrypt <newState> <toSubstring>
  44. %    Encrypts fromString according to the algorithm for Adobe
  45. %      Type 1 fonts, writing the result into toString.
  46. %      toString must be at least as long as fromString or a
  47. %      rangecheck error occurs.  state is the initial state of
  48. %      the encryption algorithm (a 16-bit non-negative
  49. %      integer); newState is the new state of the algorithm.
  50.  
  51. /.type1encrypt
  52.  { { exch pop } .type1crypt
  53.  } bind def
  54.  
  55. % <state> <fromString> <toString> .type1decrypt <newState> <toSubstring>
  56. %    Decrypts fromString according to the algorithm for Adobe
  57. %      Type 1 fonts, writing the result into toString.  Other
  58. %      specifications are as for type1encrypt.
  59.  
  60. /.type1decrypt
  61.  { { pop 2 index exch get } .type1crypt
  62.  } bind def
  63.