1
0
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:
源文雨
2023-11-21 22:53:56 +09:00
parent efe77e7d79
commit 59ec042c4b
4 changed files with 83 additions and 38 deletions

15
unix.go
View File

@@ -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)
}