H DFTACTGRP(*NO) BNDDIR('QC2LE') option(*SRCSTMT: *NODEBUGIO) H ACTGRP(*NEW) D data s 10A inz('Encrypt Me') D key s 16A varying inz('SecretKey') D encrypted s 10A D RC4_Controls ds qualified D funct_id 2A D datalen 5I 0 D operation 1A D reserved 11A D p_key_ctx * D key_ctx ds qualified D stream 256A D len 5U 0 D reserved 6A D cipher PR extproc('_CIPHER') D receiver * D control 32A D source * D p_recv s * D p_src s * /free // The following will encrypt "data" using the RC4 // algorithm with the secret key "key", and place // the result into "encrypted" key_ctx = *ALLx'00'; %subst(key_ctx.stream:1:%len(key)) = key; key_ctx.len = %len(key); RC4_Controls = *ALLx'00'; RC4_Controls.funct_id = x'0013'; RC4_Controls.datalen = %size(data); RC4_Controls.operation = x'00'; // 0=Encrypt,1=Decrypt RC4_Controls.p_key_ctx = %addr(key_ctx); p_recv = %addr(encrypted); p_src = %addr(data); cipher( p_recv: RC4_Controls: p_src); // The following will decrypt "encrypted" using the RC4 // algorithm with the secret key "key", and place the // result in "data". We blank out data ahead of time // to ensure that it's contents aren't carried over from // the code above. data = *blanks; key_ctx = *ALLx'00'; %subst(key_ctx.stream:1:%len(key)) = key; key_ctx.len = %len(key); RC4_Controls = *ALLx'00'; RC4_Controls.funct_id = x'0013'; RC4_Controls.datalen = %size(data); RC4_Controls.operation = x'01'; // 0=Encrypt,1=Decrypt RC4_Controls.p_key_ctx = %addr(key_ctx); p_recv = %addr(data); p_src = %addr(encrypted); cipher( p_recv: RC4_Controls: p_src); *inlr = *on; /end-free