mirror of
https://github.com/fumiama/go-hide-param.git
synced 2026-06-05 07:20:25 +08:00
feat: hide all param len to ***
This commit is contained in:
15
unix.go
15
unix.go
@@ -3,16 +3,9 @@
|
||||
|
||||
package gohideparam
|
||||
|
||||
import (
|
||||
"os"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Hide replace arg at position with three `*`
|
||||
//
|
||||
// or less than three if len(os.Args[position]) < 3
|
||||
func Hide(position int) {
|
||||
if position > 0 && position < len(os.Args) {
|
||||
p := *(*unsafe.Pointer)(unsafe.Pointer(&os.Args[position]))
|
||||
for i := 0; i < len(os.Args[position]); i++ {
|
||||
*(*uint8)(unsafe.Pointer(uintptr(p) + uintptr(i))) = '*'
|
||||
}
|
||||
}
|
||||
hideOSArg(position)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user