VAQHSH1 ;ALB/JRP - ENCRYPT/DECRYPT ROUTINES;29-MAR-93
;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
KRNLHASH(STRING,KEY1,KEY2,DCRYPT) ;ENCRYPT/DECRYPT USING KERNEL HASHING
;INPUT : STRING - String to encrypt/decrypt
; KEY1 - Primary key for encryption/decryption (numeric)
; (defaults to the current value in DUZ)
; KEY2 - Secondary key for encryption/decryption (numeric)
; (defaults to 0)
; DCRYPT - Flag indicating whether to encrypt or decrypt
; If 0, encrypt STRING (default)
; If 1, decrypt STRING
;OUTPUT : S - STRING encrypted/decrypted using KERNEL hashing
; Null - Encryption/decryption not possible
;
;CHECK INPUT
Q:('$D(STRING)) ""
S:('$D(KEY1)) KEY1=+$G(DUZ)
S:(KEY1'?1.N) KEY1=+$G(DUZ)
S KEY2=+$G(KEY2)
S DCRYPT=+$G(DCRYPT)
;DECLARE VARIABLES
N X,X1,X2
S X=STRING
S X1=KEY1
S X2=KEY2
;ENCRYPT
I ('DCRYPT) D EN^XUSHSHP Q X
;DECRYPT
D DE^XUSHSHP
Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVAQHSH1 999 printed Dec 13, 2024@02:25:57 Page 2
VAQHSH1 ;ALB/JRP - ENCRYPT/DECRYPT ROUTINES;29-MAR-93
+1 ;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
KRNLHASH(STRING,KEY1,KEY2,DCRYPT) ;ENCRYPT/DECRYPT USING KERNEL HASHING
+1 ;INPUT : STRING - String to encrypt/decrypt
+2 ; KEY1 - Primary key for encryption/decryption (numeric)
+3 ; (defaults to the current value in DUZ)
+4 ; KEY2 - Secondary key for encryption/decryption (numeric)
+5 ; (defaults to 0)
+6 ; DCRYPT - Flag indicating whether to encrypt or decrypt
+7 ; If 0, encrypt STRING (default)
+8 ; If 1, decrypt STRING
+9 ;OUTPUT : S - STRING encrypted/decrypted using KERNEL hashing
+10 ; Null - Encryption/decryption not possible
+11 ;
+12 ;CHECK INPUT
+13 if ('$DATA(STRING))
QUIT ""
+14 if ('$DATA(KEY1))
SET KEY1=+$GET(DUZ)
+15 if (KEY1'?1.N)
SET KEY1=+$GET(DUZ)
+16 SET KEY2=+$GET(KEY2)
+17 SET DCRYPT=+$GET(DCRYPT)
+18 ;DECLARE VARIABLES
+19 NEW X,X1,X2
+20 SET X=STRING
+21 SET X1=KEY1
+22 SET X2=KEY2
+23 ;ENCRYPT
+24 IF ('DCRYPT)
DO EN^XUSHSHP
QUIT X
+25 ;DECRYPT
+26 DO DE^XUSHSHP
+27 QUIT X