| 
									
										
										
										
											2015-11-03 21:26:16 +01:00
										 |  |  | package crypto | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"crypto/aes" | 
					
						
							|  |  |  | 	"crypto/cipher" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-26 21:21:22 +02:00
										 |  |  | // NewAesDecryptionStream creates a new AES encryption stream based on given key and IV. | 
					
						
							|  |  |  | // Caller must ensure the length of key and IV is either 16, 24 or 32 bytes. | 
					
						
							| 
									
										
										
										
											2016-02-25 21:50:10 +01:00
										 |  |  | func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream { | 
					
						
							|  |  |  | 	aesBlock, _ := aes.NewCipher(key) | 
					
						
							|  |  |  | 	return cipher.NewCFBDecrypter(aesBlock, iv) | 
					
						
							| 
									
										
										
										
											2015-11-03 21:26:16 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-26 21:21:22 +02:00
										 |  |  | // NewAesEncryptionStream creates a new AES description stream based on given key and IV. | 
					
						
							|  |  |  | // Caller must ensure the length of key and IV is either 16, 24 or 32 bytes. | 
					
						
							| 
									
										
										
										
											2016-02-25 21:50:10 +01:00
										 |  |  | func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream { | 
					
						
							|  |  |  | 	aesBlock, _ := aes.NewCipher(key) | 
					
						
							|  |  |  | 	return cipher.NewCFBEncrypter(aesBlock, iv) | 
					
						
							| 
									
										
										
										
											2015-11-03 21:26:16 +01:00
										 |  |  | } |