add encryption
This commit is contained in:
		
							
								
								
									
										21
									
								
								test/encryption.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								test/encryption.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| const test = require ('ava'); | ||||
| const crypto = require ('../index'); | ||||
|  | ||||
| test ('encryption', (t) => { | ||||
|   const enc = crypto.encrypt_aes ('foo', 'bar'); | ||||
|   t.is (typeof enc, 'string'); | ||||
| }); | ||||
|  | ||||
| test ('decryption', (t) => { | ||||
|   const enc = crypto.encrypt_aes ('foo', 'bar'); | ||||
|   const dec = crypto.decrypt_aes (enc, 'bar'); | ||||
|   t.is (dec, 'foo'); | ||||
| }); | ||||
|  | ||||
| test ('fail decryption', (t) => { | ||||
|   const enc = crypto.encrypt_aes ('foo', 'bar'); | ||||
|   const dec = crypto.decrypt_aes (enc, 'baz'); | ||||
|   t.is (dec, null); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user