mirror of
https://github.com/hashicorp/packer.git
synced 2026-03-13 22:22:08 -04:00
18 lines
326 B
Go
18 lines
326 B
Go
|
|
package powershell
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/base64"
|
||
|
|
)
|
||
|
|
|
||
|
|
func powershellEncode(buffer []byte) string {
|
||
|
|
// 2 byte chars to make PowerShell happy
|
||
|
|
wideCmd := ""
|
||
|
|
for _, b := range buffer {
|
||
|
|
wideCmd += string(b) + "\x00"
|
||
|
|
}
|
||
|
|
|
||
|
|
// Base64 encode the command
|
||
|
|
input := []uint8(wideCmd)
|
||
|
|
return base64.StdEncoding.EncodeToString(input)
|
||
|
|
}
|