mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	
		
			
	
	
		
			14 lines
		
	
	
		
			436 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			14 lines
		
	
	
		
			436 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
								 | 
							
								const test = require('tape');
							 | 
						||
| 
								 | 
							
								const data_encryption = require('../services/data_encryption');
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								test('encrypt & decrypt', t => {
							 | 
						||
| 
								 | 
							
								    const dataKey = [1,2,3];
							 | 
						||
| 
								 | 
							
								    const iv = [4,5,6];
							 | 
						||
| 
								 | 
							
								    const plainText = "Hello World!";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    const cipherText = data_encryption.encryptCbc(dataKey, iv, plainText);
							 | 
						||
| 
								 | 
							
								    const decodedPlainText = data_encryption.decryptCbc(dataKey, iv, cipherText);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    t.equal(decodedPlainText, plainText);
							 | 
						||
| 
								 | 
							
								    t.end();
							 | 
						||
| 
								 | 
							
								});
							 |