| 
					
				 | 
			
			
				@@ -0,0 +1,21 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { createCipheriv, createDecipheriv, scryptSync } from 'crypto'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import config from '@config'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const algorithm = 'aes-192-cbc'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const salt = '123'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const key = scryptSync(config.secrestKey, salt, 24); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const iv = Buffer.alloc(16, '11') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+export const cipher = (data: string) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  const cipher = createCipheriv(algorithm, key, iv); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  let enc = cipher.update(data, 'utf8', 'hex'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  enc += cipher.final('hex'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return enc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+export const decipher = (data: string) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  const decipher = createDecipheriv(algorithm, key, iv); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  let dec = decipher.update(data, 'hex', 'utf8'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  dec += decipher.final('utf8'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return dec 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |