mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	
		
			
	
	
		
			24 lines
		
	
	
		
			415 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			24 lines
		
	
	
		
			415 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package encrypt
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import "testing"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func TestRawMethod_Encrypt(t *testing.T) {
							 | 
						||
| 
								 | 
							
									method, err := NewMethodInstance("raw", "abc", "123")
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										t.Fatal(err)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									src := []byte("Hello, World")
							 | 
						||
| 
								 | 
							
									dst, err := method.Encrypt(src)
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										t.Fatal(err)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									dst = dst[:len(src)]
							 | 
						||
| 
								 | 
							
									t.Log("dst:", string(dst))
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									src, err = method.Decrypt(dst)
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										t.Fatal(err)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									t.Log("src:", string(src))
							 | 
						||
| 
								 | 
							
								}
							 |