update base64
This commit is contained in:
parent
8c2f82aba7
commit
38facbe036
2 changed files with 50 additions and 34 deletions
42
README.md
42
README.md
|
|
@ -61,6 +61,7 @@
|
||||||
- [Drawing](#drawing)
|
- [Drawing](#drawing)
|
||||||
- [ObjectEvent](#objectevent)
|
- [ObjectEvent](#objectevent)
|
||||||
- [Sockets](#sockets)
|
- [Sockets](#sockets)
|
||||||
|
- [Base64](#base64)
|
||||||
- [Excel](#excel)
|
- [Excel](#excel)
|
||||||
- [CSV](#csv)
|
- [CSV](#csv)
|
||||||
- [XML](#xml)
|
- [XML](#xml)
|
||||||
|
|
@ -3488,23 +3489,6 @@ $UdpClient.Close()
|
||||||
`Send-WOL -Mac "D8-BB-C1-70-A3-4E"` \
|
`Send-WOL -Mac "D8-BB-C1-70-A3-4E"` \
|
||||||
`Send-WOL -Mac "D8-BB-C1-70-A3-4E" -IP 192.168.3.100`
|
`Send-WOL -Mac "D8-BB-C1-70-A3-4E" -IP 192.168.3.100`
|
||||||
|
|
||||||
### Encoding
|
|
||||||
`$ByteText = [System.Text.Encoding]::UTF8.GetBytes("password")` \
|
|
||||||
`$Text = [System.Text.Encoding]::UTF8.GetString($ByteText)`
|
|
||||||
|
|
||||||
### Base64
|
|
||||||
`$text = "password"` \
|
|
||||||
`$byte = [System.Text.Encoding]::Unicode.GetBytes($text)` \
|
|
||||||
`$base64 = [System.Convert]::ToBase64String($byte)` \
|
|
||||||
`$decode_base64 = [System.Convert]::FromBase64String($base64)` \
|
|
||||||
`$decode_string = [System.Text.Encoding]::Unicode.GetString($decode_base64)`
|
|
||||||
|
|
||||||
`$path_image = "$home\Documents\1200x800.jpg"` \
|
|
||||||
`$BBase64 = [System.Convert]::ToBase64String((Get-Content $path_image -Encoding Byte))` \
|
|
||||||
`Add-Type -assembly System.Drawing` \
|
|
||||||
`$Image = [System.Drawing.Bitmap]::FromStream([IO.MemoryStream][Convert]::FromBase64String($BBase64))` \
|
|
||||||
`$Image.Save("$home\Desktop\1200x800.jpg")`
|
|
||||||
|
|
||||||
### HTTP Listener
|
### HTTP Listener
|
||||||
```PowerShell
|
```PowerShell
|
||||||
$httpListener = New-Object System.Net.HttpListener
|
$httpListener = New-Object System.Net.HttpListener
|
||||||
|
|
@ -3554,6 +3538,30 @@ $Collections
|
||||||
```
|
```
|
||||||
`Get-WebCertificate https://google.com`
|
`Get-WebCertificate https://google.com`
|
||||||
|
|
||||||
|
# Base64
|
||||||
|
|
||||||
|
### UTF8
|
||||||
|
|
||||||
|
`$loginPassword = "login:password"` \
|
||||||
|
`$Base64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($loginPassword))` закодировать логин и пароль в строку Base64 \
|
||||||
|
`[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Base64))` преобразовать в байты и обратно декодировать в исходную строку с помощью UTF-8 кодировки
|
||||||
|
|
||||||
|
### Unicode
|
||||||
|
```PowerShell
|
||||||
|
$text = "password"
|
||||||
|
$byte = [System.Text.Encoding]::Unicode.GetBytes($text) # преобразует строку $text в последовательность байтов, используя кодировку Unicode
|
||||||
|
$base64 = [System.Convert]::ToBase64String($byte) # байты конвертируются в строку Base64 с помощью метода ToBase64String
|
||||||
|
$decode_base64 = [System.Convert]::FromBase64String($base64) # декодировать строку Base64 обратно в последовательность байтов с помощью метода FromBase64String
|
||||||
|
$decode_string = [System.Text.Encoding]::Unicode.GetString($decode_base64) # закодированные байты преобразуются обратно в строку с использованием кодировки Unicode с помощью метода GetString
|
||||||
|
```
|
||||||
|
### Image
|
||||||
|
```PowerShell
|
||||||
|
$path_image = "$home\Documents\1200x800.jpg"
|
||||||
|
$BBase64 = [System.Convert]::ToBase64String((Get-Content $path_image -Encoding Byte))
|
||||||
|
Add-Type -assembly System.Drawing
|
||||||
|
$Image = [System.Drawing.Bitmap]::FromStream([IO.MemoryStream][Convert]::FromBase64String($BBase64))
|
||||||
|
$Image.Save("$home\Desktop\1200x800.jpg")
|
||||||
|
```
|
||||||
# Excel
|
# Excel
|
||||||
```PowerShell
|
```PowerShell
|
||||||
$path = "$home\Desktop\Services-to-Excel.xlsx"
|
$path = "$home\Desktop\Services-to-Excel.xlsx"
|
||||||
|
|
|
||||||
42
posh.txt
42
posh.txt
|
|
@ -61,6 +61,7 @@ Habr: PowerShell и его возможности (https://habr.com/ru/articles/
|
||||||
# Drawing
|
# Drawing
|
||||||
# ObjectEvent
|
# ObjectEvent
|
||||||
# Sockets
|
# Sockets
|
||||||
|
# Base64
|
||||||
# Excel
|
# Excel
|
||||||
# CSV
|
# CSV
|
||||||
# XML
|
# XML
|
||||||
|
|
@ -3488,23 +3489,6 @@ $UdpClient.Close()
|
||||||
Send-WOL -Mac "D8-BB-C1-70-A3-4E"
|
Send-WOL -Mac "D8-BB-C1-70-A3-4E"
|
||||||
Send-WOL -Mac "D8-BB-C1-70-A3-4E" -IP 192.168.3.100
|
Send-WOL -Mac "D8-BB-C1-70-A3-4E" -IP 192.168.3.100
|
||||||
|
|
||||||
### Encoding
|
|
||||||
$ByteText = [System.Text.Encoding]::UTF8.GetBytes("password")
|
|
||||||
$Text = [System.Text.Encoding]::UTF8.GetString($ByteText)
|
|
||||||
|
|
||||||
### Base64
|
|
||||||
$text = "password"
|
|
||||||
$byte = [System.Text.Encoding]::Unicode.GetBytes($text)
|
|
||||||
$base64 = [System.Convert]::ToBase64String($byte)
|
|
||||||
$decode_base64 = [System.Convert]::FromBase64String($base64)
|
|
||||||
$decode_string = [System.Text.Encoding]::Unicode.GetString($decode_base64)
|
|
||||||
|
|
||||||
$path_image = "$home\Documents\1200x800.jpg"
|
|
||||||
$BBase64 = [System.Convert]::ToBase64String((Get-Content $path_image -Encoding Byte))
|
|
||||||
Add-Type -assembly System.Drawing
|
|
||||||
$Image = [System.Drawing.Bitmap]::FromStream([IO.MemoryStream][Convert]::FromBase64String($BBase64))
|
|
||||||
$Image.Save("$home\Desktop\1200x800.jpg")
|
|
||||||
|
|
||||||
### HTTP Listener
|
### HTTP Listener
|
||||||
|
|
||||||
$httpListener = New-Object System.Net.HttpListener
|
$httpListener = New-Object System.Net.HttpListener
|
||||||
|
|
@ -3554,6 +3538,30 @@ $Collections
|
||||||
|
|
||||||
Get-WebCertificate https://google.com
|
Get-WebCertificate https://google.com
|
||||||
|
|
||||||
|
# Base64
|
||||||
|
|
||||||
|
### UTF8
|
||||||
|
|
||||||
|
$loginPassword = "login:password"
|
||||||
|
$Base64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($loginPassword)) # закодировать логин и пароль в строку Base64
|
||||||
|
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Base64)) # преобразовать в байты и обратно декодировать в исходную строку с помощью UTF-8 кодировки
|
||||||
|
|
||||||
|
### Unicode
|
||||||
|
|
||||||
|
$text = "password"
|
||||||
|
$byte = [System.Text.Encoding]::Unicode.GetBytes($text) # преобразует строку $text в последовательность байтов, используя кодировку Unicode
|
||||||
|
$base64 = [System.Convert]::ToBase64String($byte) # байты конвертируются в строку Base64 с помощью метода ToBase64String
|
||||||
|
$decode_base64 = [System.Convert]::FromBase64String($base64) # декодировать строку Base64 обратно в последовательность байтов с помощью метода FromBase64String
|
||||||
|
$decode_string = [System.Text.Encoding]::Unicode.GetString($decode_base64) # закодированные байты преобразуются обратно в строку с использованием кодировки Unicode с помощью метода GetString
|
||||||
|
|
||||||
|
### Image
|
||||||
|
|
||||||
|
$path_image = "$home\Documents\1200x800.jpg"
|
||||||
|
$BBase64 = [System.Convert]::ToBase64String((Get-Content $path_image -Encoding Byte))
|
||||||
|
Add-Type -assembly System.Drawing
|
||||||
|
$Image = [System.Drawing.Bitmap]::FromStream([IO.MemoryStream][Convert]::FromBase64String($BBase64))
|
||||||
|
$Image.Save("$home\Desktop\1200x800.jpg")
|
||||||
|
|
||||||
# Excel
|
# Excel
|
||||||
|
|
||||||
$path = "$home\Desktop\Services-to-Excel.xlsx"
|
$path = "$home\Desktop\Services-to-Excel.xlsx"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue