hide error messages in non-debug mode
This commit is contained in:
		
							parent
							
								
									3c6920df6b
								
							
						
					
					
						commit
						4c43773989
					
				
							
								
								
									
										18
									
								
								main.go
								
								
								
								
							
							
						
						
									
										18
									
								
								main.go
								
								
								
								
							|  | @ -9,13 +9,20 @@ import ( | ||||||
|   "io" |   "io" | ||||||
|   "io/ioutil" |   "io/ioutil" | ||||||
|   "os" |   "os" | ||||||
|  | //  "strings"
 | ||||||
|   "syscall" |   "syscall" | ||||||
|   "golang.org/x/crypto/ssh/terminal" |   "golang.org/x/crypto/ssh/terminal" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | var debug bool = false | ||||||
|  | 
 | ||||||
| func checkErr(err error) { | func checkErr(err error) { | ||||||
|   if err != nil { |   if err != nil { | ||||||
|     panic(err.Error()) |     if debug { | ||||||
|  |       panic(err.Error()) | ||||||
|  |     } else { | ||||||
|  |       os.Exit(1) | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -126,7 +133,14 @@ func main() { | ||||||
|       secretfn := fn + ".hdn" |       secretfn := fn + ".hdn" | ||||||
|       data2file(secretfn,secret) |       data2file(secretfn,secret) | ||||||
|     case "s": |     case "s": | ||||||
|       fmt.Println("decrypt") |       fmt.Print("password: ") | ||||||
|  |       pw := readPass() | ||||||
|  |       fmt.Print("\n") | ||||||
|  |       key := keyMkr(pw) | ||||||
|  |       secret := file2data(fn) | ||||||
|  |       datafn := fn + "clear" | ||||||
|  |       data := decrypt(secret, key) | ||||||
|  |       data2file(datafn, data) | ||||||
|   } |   } | ||||||
|   /* |   /* | ||||||
|   var passwd string = "ThisAnnPassphrase" |   var passwd string = "ThisAnnPassphrase" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue