      $SET COMP           ANS85 NOTRUNC DEFAULTBYTE"00"
       identification division.
      *----------------------------------------------------------------*
      * dfhucry1.cbl
      *----------------------------------------------------------------*
      * Copyright (C) 1998-2006 Micro Focus (IP) Limited. 
      * All rights reserved.
      *  
      * This demonstration program is provided for use by users of 
      * Micro Focus products (the "Software") and may be used,
      * modified and distributed as part of your application provided 
      * that you properly acknowledge the copyright of Micro Focus in this
      * material.
      *     
      * All conditions, warranties and undertakings, express or implied, 
      * statutory or otherwise, on the part of Micro Focus are excluded,
      * including without limitation those of merchantability or fitness  
      * for purpose. This shall not, however, purport to exclude or 
      * restrict the liability of Micro Focus to any extent not
      * permitted by law.
      *
      * IN NO EVENT WILL MICRO FOCUS BE LIABLE FOR ANY INDIRECT,
      * INCIDENTAL, SPECIAL, CONSEQUENTIAL OR OTHER DAMAGES ARISING OUT 
      * OF THE USE OF THE DEMONSTRATION PROGRAM DISTRIBUTED WITH THE 
      * SOFTWARE, WHETHER OR NOT INFORMED OF THE POSSIBILITIES OF 
      * DAMAGES IN ADVANCE.  THESE LIMITATIONS APPLY TO ALL CAUSES OF 
      * ACTION, INCLUDING BREACH OF CONTRACT, BREACH OF WARRANTY, STRICT
      * LIABILITY, AND ANY ACTIONS IN TORTS.
      *----------------------------------------------------------------*

       environment division.

       working-storage section.

       78  cobol-pack-byte             value x'F4'.
       78  cobol-unpack-byte           value x'F5'.

       01  crypt-work-areas.
           05  work-user-id            pic x(8)    value spaces.
           05  work-password           pic x(8)    value spaces.

           05  work-shift-count        pic xx      value 0     comp-5.
           05  work-shift              pic xx      value 0     comp-5.

           05  work-sub                pic xx      value 0     comp-5.
           05  work-idx                pic xx      value 0     comp-x.
           05              redefines   work-idx.
               10                      pic x.
               10  work-idx-byte.
                   15  work-idx-byte-n pic x       comp-x.

           05  work-password-bytes.
               10  work-password-byte  pic x(8)    occurs 8.
           05              redefines   work-password-bytes.
               10  work-password-bit   pic x       occurs 64   comp-x.


           05  work-password-shift.
               10  work-shift-byte     pic x(8)    occurs 8.
           05              redefines   work-password-shift.
               10  work-shift-bit      pic x       occurs 64   comp-x.

      ***-------------------------------------------------------------*

           05  encypher-table.
               10          pic x       comp-x      value 036.
               10          pic x       comp-x      value 168.
               10          pic x       comp-x      value 066.
               10          pic x       comp-x      value 197.
               10          pic x       comp-x      value 004.
               10          pic x       comp-x      value 061.
               10          pic x       comp-x      value 016.
               10          pic x       comp-x      value 182.
               10          pic x       comp-x      value 092.
               10          pic x       comp-x      value 170.
               10          pic x       comp-x      value 220.
               10          pic x       comp-x      value 129.
               10          pic x       comp-x      value 167.
               10          pic x       comp-x      value 202.
               10          pic x       comp-x      value 114.
               10          pic x       comp-x      value 190.
               10          pic x       comp-x      value 140.
               10          pic x       comp-x      value 040.
               10          pic x       comp-x      value 000.
               10          pic x       comp-x      value 223.
               10          pic x       comp-x      value 090.
               10          pic x       comp-x      value 067.
               10          pic x       comp-x      value 250.
               10          pic x       comp-x      value 238.
               10          pic x       comp-x      value 180.
               10          pic x       comp-x      value 085.
               10          pic x       comp-x      value 075.
               10          pic x       comp-x      value 145.
               10          pic x       comp-x      value 102.
               10          pic x       comp-x      value 131.
               10          pic x       comp-x      value 236.
               10          pic x       comp-x      value 077.
               10          pic x       comp-x      value 239.
               10          pic x       comp-x      value 045.
               10          pic x       comp-x      value 230.
               10          pic x       comp-x      value 157.
               10          pic x       comp-x      value 100.
               10          pic x       comp-x      value 214.
               10          pic x       comp-x      value 108.
               10          pic x       comp-x      value 191.
               10          pic x       comp-x      value 011.
               10          pic x       comp-x      value 134.
               10          pic x       comp-x      value 005.
               10          pic x       comp-x      value 227.
               10          pic x       comp-x      value 222.
               10          pic x       comp-x      value 200.
               10          pic x       comp-x      value 058.
               10          pic x       comp-x      value 147.
               10          pic x       comp-x      value 152.
               10          pic x       comp-x      value 035.
               10          pic x       comp-x      value 095.
               10          pic x       comp-x      value 253.
               10          pic x       comp-x      value 228.
               10          pic x       comp-x      value 015.
               10          pic x       comp-x      value 021.
               10          pic x       comp-x      value 201.
               10          pic x       comp-x      value 193.
               10          pic x       comp-x      value 160.
               10          pic x       comp-x      value 065.
               10          pic x       comp-x      value 225.
               10          pic x       comp-x      value 047.
               10          pic x       comp-x      value 137.
               10          pic x       comp-x      value 110.
               10          pic x       comp-x      value 001.
               10          pic x       comp-x      value 204.
               10          pic x       comp-x      value 112.
               10          pic x       comp-x      value 209.
               10          pic x       comp-x      value 245.
               10          pic x       comp-x      value 072.
               10          pic x       comp-x      value 158.
               10          pic x       comp-x      value 106.
               10          pic x       comp-x      value 068.
               10          pic x       comp-x      value 030.
               10          pic x       comp-x      value 050.
               10          pic x       comp-x      value 020.
               10          pic x       comp-x      value 115.
               10          pic x       comp-x      value 088.
               10          pic x       comp-x      value 144.
               10          pic x       comp-x      value 083.
               10          pic x       comp-x      value 255.
               10          pic x       comp-x      value 234.
               10          pic x       comp-x      value 164.
               10          pic x       comp-x      value 101.
               10          pic x       comp-x      value 007.
               10          pic x       comp-x      value 139.
               10          pic x       comp-x      value 025.
               10          pic x       comp-x      value 185.
               10          pic x       comp-x      value 161.
               10          pic x       comp-x      value 049.
               10          pic x       comp-x      value 056.
               10          pic x       comp-x      value 024.
               10          pic x       comp-x      value 022.
               10          pic x       comp-x      value 048.
               10          pic x       comp-x      value 052.
               10          pic x       comp-x      value 171.
               10          pic x       comp-x      value 178.
               10          pic x       comp-x      value 046.
               10          pic x       comp-x      value 210.
               10          pic x       comp-x      value 192.
               10          pic x       comp-x      value 153.
               10          pic x       comp-x      value 235.
               10          pic x       comp-x      value 017.
               10          pic x       comp-x      value 074.
               10          pic x       comp-x      value 038.
               10          pic x       comp-x      value 105.
               10          pic x       comp-x      value 241.
               10          pic x       comp-x      value 229.
               10          pic x       comp-x      value 037.
               10          pic x       comp-x      value 028.
               10          pic x       comp-x      value 244.
               10          pic x       comp-x      value 248.
               10          pic x       comp-x      value 073.
               10          pic x       comp-x      value 252.
               10          pic x       comp-x      value 132.
               10          pic x       comp-x      value 009.
               10          pic x       comp-x      value 125.
               10          pic x       comp-x      value 039.
               10          pic x       comp-x      value 242.
               10          pic x       comp-x      value 173.
               10          pic x       comp-x      value 249.
               10          pic x       comp-x      value 141.
               10          pic x       comp-x      value 163.
               10          pic x       comp-x      value 135.
               10          pic x       comp-x      value 226.
               10          pic x       comp-x      value 062.
               10          pic x       comp-x      value 044.
               10          pic x       comp-x      value 155.
               10          pic x       comp-x      value 215.
               10          pic x       comp-x      value 033.
               10          pic x       comp-x      value 183.
               10          pic x       comp-x      value 143.
               10          pic x       comp-x      value 117.
               10          pic x       comp-x      value 175.
               10          pic x       comp-x      value 213.
               10          pic x       comp-x      value 018.
               10          pic x       comp-x      value 084.
               10          pic x       comp-x      value 026.
               10          pic x       comp-x      value 078.
               10          pic x       comp-x      value 031.
               10          pic x       comp-x      value 023.
               10          pic x       comp-x      value 205.
               10          pic x       comp-x      value 240.
               10          pic x       comp-x      value 041.
               10          pic x       comp-x      value 218.
               10          pic x       comp-x      value 174.
               10          pic x       comp-x      value 243.
               10          pic x       comp-x      value 027.
               10          pic x       comp-x      value 217.
               10          pic x       comp-x      value 212.
               10          pic x       comp-x      value 118.
               10          pic x       comp-x      value 096.
               10          pic x       comp-x      value 231.
               10          pic x       comp-x      value 043.
               10          pic x       comp-x      value 059.
               10          pic x       comp-x      value 136.
               10          pic x       comp-x      value 130.
               10          pic x       comp-x      value 206.
               10          pic x       comp-x      value 109.
               10          pic x       comp-x      value 107.
               10          pic x       comp-x      value 097.
               10          pic x       comp-x      value 199.
               10          pic x       comp-x      value 181.
               10          pic x       comp-x      value 142.
               10          pic x       comp-x      value 169.
               10          pic x       comp-x      value 070.
               10          pic x       comp-x      value 098.
               10          pic x       comp-x      value 247.
               10          pic x       comp-x      value 086.
               10          pic x       comp-x      value 089.
               10          pic x       comp-x      value 034.
               10          pic x       comp-x      value 060.
               10          pic x       comp-x      value 216.
               10          pic x       comp-x      value 146.
               10          pic x       comp-x      value 176.
               10          pic x       comp-x      value 254.
               10          pic x       comp-x      value 186.
               10          pic x       comp-x      value 010.
               10          pic x       comp-x      value 042.
               10          pic x       comp-x      value 121.
               10          pic x       comp-x      value 203.
               10          pic x       comp-x      value 053.
               10          pic x       comp-x      value 104.
               10          pic x       comp-x      value 071.
               10          pic x       comp-x      value 207.
               10          pic x       comp-x      value 111.
               10          pic x       comp-x      value 154.
               10          pic x       comp-x      value 165.
               10          pic x       comp-x      value 184.
               10          pic x       comp-x      value 189.
               10          pic x       comp-x      value 179.
               10          pic x       comp-x      value 172.
               10          pic x       comp-x      value 006.
               10          pic x       comp-x      value 057.
               10          pic x       comp-x      value 124.
               10          pic x       comp-x      value 194.
               10          pic x       comp-x      value 051.
               10          pic x       comp-x      value 103.
               10          pic x       comp-x      value 064.
               10          pic x       comp-x      value 133.
               10          pic x       comp-x      value 187.
               10          pic x       comp-x      value 123.
               10          pic x       comp-x      value 013.
               10          pic x       comp-x      value 069.
               10          pic x       comp-x      value 211.
               10          pic x       comp-x      value 208.
               10          pic x       comp-x      value 219.
               10          pic x       comp-x      value 237.
               10          pic x       comp-x      value 246.
               10          pic x       comp-x      value 119.
               10          pic x       comp-x      value 087.
               10          pic x       comp-x      value 012.
               10          pic x       comp-x      value 151.
               10          pic x       comp-x      value 019.
               10          pic x       comp-x      value 138.
               10          pic x       comp-x      value 188.
               10          pic x       comp-x      value 177.
               10          pic x       comp-x      value 032.
               10          pic x       comp-x      value 233.
               10          pic x       comp-x      value 122.
               10          pic x       comp-x      value 099.
               10          pic x       comp-x      value 116.
               10          pic x       comp-x      value 080.
               10          pic x       comp-x      value 221.
               10          pic x       comp-x      value 251.
               10          pic x       comp-x      value 008.
               10          pic x       comp-x      value 126.
               10          pic x       comp-x      value 232.
               10          pic x       comp-x      value 076.
               10          pic x       comp-x      value 091.
               10          pic x       comp-x      value 166.
               10          pic x       comp-x      value 198.
               10          pic x       comp-x      value 002.
               10          pic x       comp-x      value 082.
               10          pic x       comp-x      value 148.
               10          pic x       comp-x      value 093.
               10          pic x       comp-x      value 079.
               10          pic x       comp-x      value 150.
               10          pic x       comp-x      value 003.
               10          pic x       comp-x      value 120.
               10          pic x       comp-x      value 195.
               10          pic x       comp-x      value 055.
               10          pic x       comp-x      value 196.
               10          pic x       comp-x      value 094.
               10          pic x       comp-x      value 128.
               10          pic x       comp-x      value 014.
               10          pic x       comp-x      value 149.
               10          pic x       comp-x      value 224.
               10          pic x       comp-x      value 162.
               10          pic x       comp-x      value 156.
               10          pic x       comp-x      value 063.
               10          pic x       comp-x      value 159.
               10          pic x       comp-x      value 081.
               10          pic x       comp-x      value 113.
               10          pic x       comp-x      value 054.
               10          pic x       comp-x      value 029.
               10          pic x       comp-x      value 127.
           05          redefines   encypher-table.
               10  cypher-byte         pic x       occurs 256.

      ***-------------------------------------------------------------*

           05  decypher-table.
               10          pic x       comp-x      value 018.
               10          pic x       comp-x      value 063.
               10          pic x       comp-x      value 231.
               10          pic x       comp-x      value 237.
               10          pic x       comp-x      value 004.
               10          pic x       comp-x      value 042.
               10          pic x       comp-x      value 191.
               10          pic x       comp-x      value 083.
               10          pic x       comp-x      value 224.
               10          pic x       comp-x      value 114.
               10          pic x       comp-x      value 176.
               10          pic x       comp-x      value 040.
               10          pic x       comp-x      value 210.
               10          pic x       comp-x      value 201.
               10          pic x       comp-x      value 244.
               10          pic x       comp-x      value 053.
               10          pic x       comp-x      value 006.
               10          pic x       comp-x      value 101.
               10          pic x       comp-x      value 134.
               10          pic x       comp-x      value 212.
               10          pic x       comp-x      value 074.
               10          pic x       comp-x      value 054.
               10          pic x       comp-x      value 091.
               10          pic x       comp-x      value 139.
               10          pic x       comp-x      value 090.
               10          pic x       comp-x      value 085.
               10          pic x       comp-x      value 136.
               10          pic x       comp-x      value 146.
               10          pic x       comp-x      value 108.
               10          pic x       comp-x      value 254.
               10          pic x       comp-x      value 072.
               10          pic x       comp-x      value 138.
               10          pic x       comp-x      value 216.
               10          pic x       comp-x      value 128.
               10          pic x       comp-x      value 169.
               10          pic x       comp-x      value 049.
               10          pic x       comp-x      value 000.
               10          pic x       comp-x      value 107.
               10          pic x       comp-x      value 103.
               10          pic x       comp-x      value 116.
               10          pic x       comp-x      value 017.
               10          pic x       comp-x      value 142.
               10          pic x       comp-x      value 177.
               10          pic x       comp-x      value 152.
               10          pic x       comp-x      value 125.
               10          pic x       comp-x      value 033.
               10          pic x       comp-x      value 096.
               10          pic x       comp-x      value 060.
               10          pic x       comp-x      value 092.
               10          pic x       comp-x      value 088.
               10          pic x       comp-x      value 073.
               10          pic x       comp-x      value 195.
               10          pic x       comp-x      value 093.
               10          pic x       comp-x      value 180.
               10          pic x       comp-x      value 253.
               10          pic x       comp-x      value 240.
               10          pic x       comp-x      value 089.
               10          pic x       comp-x      value 192.
               10          pic x       comp-x      value 046.
               10          pic x       comp-x      value 153.
               10          pic x       comp-x      value 170.
               10          pic x       comp-x      value 005.
               10          pic x       comp-x      value 124.
               10          pic x       comp-x      value 249.
               10          pic x       comp-x      value 197.
               10          pic x       comp-x      value 058.
               10          pic x       comp-x      value 002.
               10          pic x       comp-x      value 021.
               10          pic x       comp-x      value 071.
               10          pic x       comp-x      value 202.
               10          pic x       comp-x      value 164.
               10          pic x       comp-x      value 182.
               10          pic x       comp-x      value 068.
               10          pic x       comp-x      value 111.
               10          pic x       comp-x      value 102.
               10          pic x       comp-x      value 026.
               10          pic x       comp-x      value 227.
               10          pic x       comp-x      value 031.
               10          pic x       comp-x      value 137.
               10          pic x       comp-x      value 235.
               10          pic x       comp-x      value 221.
               10          pic x       comp-x      value 251.
               10          pic x       comp-x      value 232.
               10          pic x       comp-x      value 078.
               10          pic x       comp-x      value 135.
               10          pic x       comp-x      value 025.
               10          pic x       comp-x      value 167.
               10          pic x       comp-x      value 209.
               10          pic x       comp-x      value 076.
               10          pic x       comp-x      value 168.
               10          pic x       comp-x      value 020.
               10          pic x       comp-x      value 228.
               10          pic x       comp-x      value 008.
               10          pic x       comp-x      value 234.
               10          pic x       comp-x      value 242.
               10          pic x       comp-x      value 050.
               10          pic x       comp-x      value 150.
               10          pic x       comp-x      value 159.
               10          pic x       comp-x      value 165.
               10          pic x       comp-x      value 219.
               10          pic x       comp-x      value 036.
               10          pic x       comp-x      value 082.
               10          pic x       comp-x      value 028.
               10          pic x       comp-x      value 196.
               10          pic x       comp-x      value 181.
               10          pic x       comp-x      value 104.
               10          pic x       comp-x      value 070.
               10          pic x       comp-x      value 158.
               10          pic x       comp-x      value 038.
               10          pic x       comp-x      value 157.
               10          pic x       comp-x      value 062.
               10          pic x       comp-x      value 184.
               10          pic x       comp-x      value 065.
               10          pic x       comp-x      value 252.
               10          pic x       comp-x      value 014.
               10          pic x       comp-x      value 075.
               10          pic x       comp-x      value 220.
               10          pic x       comp-x      value 131.
               10          pic x       comp-x      value 149.
               10          pic x       comp-x      value 208.
               10          pic x       comp-x      value 238.
               10          pic x       comp-x      value 178.
               10          pic x       comp-x      value 218.
               10          pic x       comp-x      value 200.
               10          pic x       comp-x      value 193.
               10          pic x       comp-x      value 115.
               10          pic x       comp-x      value 225.
               10          pic x       comp-x      value 255.
               10          pic x       comp-x      value 243.
               10          pic x       comp-x      value 011.
               10          pic x       comp-x      value 155.
               10          pic x       comp-x      value 029.
               10          pic x       comp-x      value 113.
               10          pic x       comp-x      value 198.
               10          pic x       comp-x      value 041.
               10          pic x       comp-x      value 122.
               10          pic x       comp-x      value 154.
               10          pic x       comp-x      value 061.
               10          pic x       comp-x      value 213.
               10          pic x       comp-x      value 084.
               10          pic x       comp-x      value 016.
               10          pic x       comp-x      value 120.
               10          pic x       comp-x      value 162.
               10          pic x       comp-x      value 130.
               10          pic x       comp-x      value 077.
               10          pic x       comp-x      value 027.
               10          pic x       comp-x      value 172.
               10          pic x       comp-x      value 047.
               10          pic x       comp-x      value 233.
               10          pic x       comp-x      value 245.
               10          pic x       comp-x      value 236.
               10          pic x       comp-x      value 211.
               10          pic x       comp-x      value 048.
               10          pic x       comp-x      value 099.
               10          pic x       comp-x      value 185.
               10          pic x       comp-x      value 126.
               10          pic x       comp-x      value 248.
               10          pic x       comp-x      value 035.
               10          pic x       comp-x      value 069.
               10          pic x       comp-x      value 250.
               10          pic x       comp-x      value 057.
               10          pic x       comp-x      value 087.
               10          pic x       comp-x      value 247.
               10          pic x       comp-x      value 121.
               10          pic x       comp-x      value 081.
               10          pic x       comp-x      value 186.
               10          pic x       comp-x      value 229.
               10          pic x       comp-x      value 012.
               10          pic x       comp-x      value 001.
               10          pic x       comp-x      value 163.
               10          pic x       comp-x      value 009.
               10          pic x       comp-x      value 094.
               10          pic x       comp-x      value 190.
               10          pic x       comp-x      value 118.
               10          pic x       comp-x      value 144.
               10          pic x       comp-x      value 132.
               10          pic x       comp-x      value 173.
               10          pic x       comp-x      value 215.
               10          pic x       comp-x      value 095.
               10          pic x       comp-x      value 189.
               10          pic x       comp-x      value 024.
               10          pic x       comp-x      value 161.
               10          pic x       comp-x      value 007.
               10          pic x       comp-x      value 129.
               10          pic x       comp-x      value 187.
               10          pic x       comp-x      value 086.
               10          pic x       comp-x      value 175.
               10          pic x       comp-x      value 199.
               10          pic x       comp-x      value 214.
               10          pic x       comp-x      value 188.
               10          pic x       comp-x      value 015.
               10          pic x       comp-x      value 039.
               10          pic x       comp-x      value 098.
               10          pic x       comp-x      value 056.
               10          pic x       comp-x      value 194.
               10          pic x       comp-x      value 239.
               10          pic x       comp-x      value 241.
               10          pic x       comp-x      value 003.
               10          pic x       comp-x      value 230.
               10          pic x       comp-x      value 160.
               10          pic x       comp-x      value 045.
               10          pic x       comp-x      value 055.
               10          pic x       comp-x      value 013.
               10          pic x       comp-x      value 179.
               10          pic x       comp-x      value 064.
               10          pic x       comp-x      value 140.
               10          pic x       comp-x      value 156.
               10          pic x       comp-x      value 183.
               10          pic x       comp-x      value 204.
               10          pic x       comp-x      value 066.
               10          pic x       comp-x      value 097.
               10          pic x       comp-x      value 203.
               10          pic x       comp-x      value 148.
               10          pic x       comp-x      value 133.
               10          pic x       comp-x      value 037.
               10          pic x       comp-x      value 127.
               10          pic x       comp-x      value 171.
               10          pic x       comp-x      value 147.
               10          pic x       comp-x      value 143.
               10          pic x       comp-x      value 205.
               10          pic x       comp-x      value 010.
               10          pic x       comp-x      value 222.
               10          pic x       comp-x      value 044.
               10          pic x       comp-x      value 019.
               10          pic x       comp-x      value 246.
               10          pic x       comp-x      value 059.
               10          pic x       comp-x      value 123.
               10          pic x       comp-x      value 043.
               10          pic x       comp-x      value 052.
               10          pic x       comp-x      value 106.
               10          pic x       comp-x      value 034.
               10          pic x       comp-x      value 151.
               10          pic x       comp-x      value 226.
               10          pic x       comp-x      value 217.
               10          pic x       comp-x      value 080.
               10          pic x       comp-x      value 100.
               10          pic x       comp-x      value 030.
               10          pic x       comp-x      value 206.
               10          pic x       comp-x      value 023.
               10          pic x       comp-x      value 032.
               10          pic x       comp-x      value 141.
               10          pic x       comp-x      value 105.
               10          pic x       comp-x      value 117.
               10          pic x       comp-x      value 145.
               10          pic x       comp-x      value 109.
               10          pic x       comp-x      value 067.
               10          pic x       comp-x      value 207.
               10          pic x       comp-x      value 166.
               10          pic x       comp-x      value 110.
               10          pic x       comp-x      value 119.
               10          pic x       comp-x      value 022.
               10          pic x       comp-x      value 223.
               10          pic x       comp-x      value 112.
               10          pic x       comp-x      value 051.
               10          pic x       comp-x      value 174.
               10          pic x       comp-x      value 079.
           05          redefines   decypher-table.
               10  clear-byte          pic x       occurs 256.

      ***-------------------------------------------------------------*

       linkage section.

       01  crypt-parameter-area.
           05  crypt-function              pic xx  comp-x.
               88  crypt-encrypt-88            value 1.
               88  crypt-decrypt-88            value 2.
           05  crypt-result                pic xx  comp-x.
               88  crypt-successful-88         value 0.
               88  crypt-failed-88             value 1.
           05  crypt-user-id               pic x(8).
           05  crypt-encrypted-password pic x(8).
           05  crypt-decrypted-password pic x(8).

      ***-------------------------------------------------------------*

       procedure division
                   using   crypt-parameter-area
                   .

           evaluate true

               when crypt-encrypt-88
                   perform password-encryption-process

               when crypt-decrypt-88
                   perform password-decryption-process

               when other
                   set crypt-failed-88 to true

           end-evaluate

           exit program
           .

      ***-------------------------------------------------------------*

       password-encryption-process section.

           move crypt-user-id              to work-user-id
           move crypt-decrypted-password   to work-password

           perform password-bit-shift

           move 1                      to work-sub
           perform until exit
               move 0                  to work-idx
               move work-password (work-sub:1)
                                       to work-idx-byte
               add  1                  to work-idx
               move cypher-byte (work-idx)
                                       to work-password (work-sub:1)
               if work-sub = 8
                   exit perform
               else
                   add  1              to work-sub
               end-if
           end-perform

           move work-password          to crypt-encrypted-password
           set  crypt-successful-88 to true
           .

      ***-------------------------------------------------------------*

       password-decryption-process section.

           move crypt-user-id              to work-user-id
           move crypt-encrypted-password   to work-password

           move 1                      to work-sub
           perform until exit
               move 0                  to work-idx
               move work-password (work-sub:1)
                                       to work-idx-byte
               add  1                  to work-idx
               move clear-byte (work-idx)
                                       to work-password (work-sub:1)
               if work-sub = 8
                   exit perform
               else
                   add  1              to work-sub
               end-if
           end-perform

           perform password-bit-shift

           move work-password          to crypt-decrypted-password
           set  crypt-successful-88 to true
           .

      ***-------------------------------------------------------------*

       password-bit-shift section.

      ***  -- Unpack Userid Bytes
           move 1                      to work-sub
           perform until exit
               call cobol-unpack-byte
                   using   work-user-id (work-sub:1)
                           work-shift-byte (work-sub)
               end-call
               if work-sub = 8
                   exit perform
               else
                   add  1              to work-sub
               end-if
           end-perform

      ***  -- Count 1-bits in the Userid
           move 0                      to work-shift-count
           move 1                      to work-sub
           perform until exit
               if work-shift-bit (work-sub) = 1
                   add 1               to work-shift-count
               end-if
               if work-sub = 64
                   exit perform
               else
                   add  1              to work-sub
               end-if
           end-perform

      ***  -- Unpack Password Bytes
           move 1                      to work-sub
           perform until exit
               call cobol-unpack-byte
                   using   work-password (work-sub:1)
                           work-password-byte (work-sub)
               end-call
               if work-sub = 8
                   exit perform
               else
                   add  1              to work-sub
               end-if
           end-perform

      ***  --  Shift all the bits in the Password
           move 1                      to work-sub
           if crypt-decrypt-88
               move 65                     to work-shift
               subtract work-shift-count from work-shift
           else
               move 1                      to work-shift
               add  work-shift-count       to work-shift
           end-if
           perform until exit
                if work-shift = 65
                    move 1             to work-shift
                end-if
                move work-password-bit (work-sub)
                                       to work-shift-bit (work-shift)
                if work-sub = 64
                    exit perform
                else
                    add 1              to work-sub
                    add 1              to work-shift
                end-if
           end-perform

      ***  -- Pack Password Bytes
           move 1                      to work-sub
           perform until exit
               call cobol-pack-byte
                   using   work-password (work-sub:1)
                           work-shift-byte (work-sub)
               end-call
               if work-sub = 8
                   exit perform
               else
                   add  1              to work-sub
               end-if
           end-perform
           .
