Why Nostr? What is Njump?
2024-09-14 21:57:52
in reply to

ReplyGuy on wss://nostr.fmt.wiz.biz on Nostr: encrypt message platform independent. open source. Use and Share. windows only. as ...

encrypt message platform independent. open source. Use and Share. windows only. as easy as 1 2 3

1. Open the Notepad and Name the file > messageAES256.ps1> save

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

# Function to generate a 12-character strong password
function Generate-Password {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()"
$password = -join ((65..90) + (97..122) + (48..57) + (33..47) | Get-Random -Count 12 | ForEach-Object { [char]$_ })
return $password
}

# Function to Encrypt the Message using AES-256
function Encrypt-Message {
param (
[string]$Message,
[string]$Password
)

# Ensure AES-256 by deriving a 32-byte (256-bit) key from the password
$key = [System.Text.Encoding]::UTF8.GetBytes($Password.PadRight(32).Substring(0,32))
$Aes = [System.Security.Cryptography.Aes]::Create()
$Aes.KeySize = 256 # Ensure AES-256 key size
$Aes.GenerateIV()

$Aes.Key = $key
$Encryptor = $Aes.CreateEncryptor()
$MessageBytes = [System.Text.Encoding]::UTF8.GetBytes($Message)
$EncryptedMessage = $Encryptor.TransformFinalBlock($MessageBytes, 0, $MessageBytes.Length)

# Return encrypted message as Base64 encoded string (IV + CipherText)
return [Convert]::ToBase64String($Aes.IV + $EncryptedMessage)
}

# Function to Decrypt the Message using AES-256
function Decrypt-Message {
param (
[string]$EncryptedMessage,
[string]$Password
)

# Ensure AES-256 by deriving a 32-byte (256-bit) key from the password
$key = [System.Text.Encoding]::UTF8.GetBytes($Password.PadRight(32).Substring(0,32))
$Aes = [System.Security.Cryptography.Aes]::Create()
$Aes.KeySize = 256 # Ensure AES-256 key size

$EncryptedBytes = [Convert]::FromBase64String($EncryptedMessage)
$IV = $EncryptedBytes[0..15] # Extract the IV (first 16 bytes)
$CipherText = $EncryptedBytes[16..($EncryptedBytes.Length - 1)]

$Aes.IV = $IV
$Aes.Key = $key
$Decryptor = $Aes.CreateDecryptor()

# Decrypt the message
$DecryptedMessage = $Decryptor.TransformFinalBlock($CipherText, 0, $CipherText.Length)
return [System.Text.Encoding]::UTF8.GetString($DecryptedMessage)
}

# Generate a password when the program opens
$generatedPassword = Generate-Password

# Create a Form
$form = New-Object system.Windows.Forms.Form
$form.Text = "AES-256 Encrypt/Decrypt"
$form.Size = New-Object System.Drawing.Size(450, 430) # Increased window size
$form.StartPosition = "CenterScreen"

# Add a warning label above the password field
$warningLabel = New-Object System.Windows.Forms.Label
$warningLabel.Text = "Share this password and this program > separated < with the message destination with caution."
$warningLabel.Location = New-Object System.Drawing.Point(10, 5)
$warningLabel.Size = New-Object System.Drawing.Size(420, 40)
$form.Controls.Add($warningLabel)

# Add an additional custom text if needed
$additionalTextLabel = New-Object System.Windows.Forms.Label
$additionalTextLabel.Text = "You can use the passord you already have or this new one."
$additionalTextLabel.Location = New-Object System.Drawing.Point(10, 40)
$additionalTextLabel.Size = New-Object System.Drawing.Size(420, 20)
$form.Controls.Add($additionalTextLabel)

# Create a Label for Password
$passwordLabel = New-Object System.Windows.Forms.Label
$passwordLabel.Text = "Password (Auto-Generated):"
$passwordLabel.Location = New-Object System.Drawing.Point(10, 70)
$passwordLabel.Size = New-Object System.Drawing.Size(150, 20)
$form.Controls.Add($passwordLabel)

# Create a TextBox for Password (pre-filled with the generated password, unmasked)
$passwordTextBox = New-Object System.Windows.Forms.TextBox
$passwordTextBox.Location = New-Object System.Drawing.Point(170, 70)
$passwordTextBox.Size = New-Object System.Drawing.Size(250, 20)
$passwordTextBox.Text = $generatedPassword
$form.Controls.Add($passwordTextBox)

# Create a Label for Message
$messageLabel = New-Object System.Windows.Forms.Label
$messageLabel.Text = "Message:"
$messageLabel.Location = New-Object System.Drawing.Point(10, 110)
$messageLabel.Size = New-Object System.Drawing.Size(100, 20)
$form.Controls.Add($messageLabel)

# Create a TextBox for Message
$messageTextBox = New-Object System.Windows.Forms.TextBox
$messageTextBox.Location = New-Object System.Drawing.Point(120, 110)
$messageTextBox.Size = New-Object System.Drawing.Size(300, 100)
$messageTextBox.Multiline = $true
$form.Controls.Add($messageTextBox)

# Create a Label for Result
$resultLabel = New-Object System.Windows.Forms.Label
$resultLabel.Text = "Result:"
$resultLabel.Location = New-Object System.Drawing.Point(10, 230)
$resultLabel.Size = New-Object System.Drawing.Size(100, 20)
$form.Controls.Add($resultLabel)

# Create a TextBox for Result (matching size and style to the message field)
$resultTextBox = New-Object System.Windows.Forms.TextBox
$resultTextBox.Location = New-Object System.Drawing.Point(120, 230)
$resultTextBox.Size = New-Object System.Drawing.Size(300, 100)
$resultTextBox.Multiline = $true
$form.Controls.Add($resultTextBox)

# Create an Encrypt Button
$encryptButton = New-Object System.Windows.Forms.Button
$encryptButton.Text = "Encrypt"
$encryptButton.Location = New-Object System.Drawing.Point(80, 350) # Adjusted location
$encryptButton.Size = New-Object System.Drawing.Size(100, 30)
$form.Controls.Add($encryptButton)

# Create a Decrypt Button
$decryptButton = New-Object System.Windows.Forms.Button
$decryptButton.Text = "Decrypt"
$decryptButton.Location = New-Object System.Drawing.Point(240, 350) # Adjusted location
$decryptButton.Size = New-Object System.Drawing.Size(100, 30)
$form.Controls.Add($decryptButton)

# Event Handler for Encrypt Button
$encryptButton.Add_Click({
$message = $messageTextBox.Text
$password = $passwordTextBox.Text

if (-not [string]::IsNullOrEmpty($message) -and -not [string]::IsNullOrEmpty($password)) {
$encryptedMessage = Encrypt-Message -Message $message -Password $password
$resultTextBox.Text = $encryptedMessage
} else {
[System.Windows.Forms.MessageBox]::Show("Please provide both a message and a password.", "Error")
}
})

# Event Handler for Decrypt Button
$decryptButton.Add_Click({
$encryptedMessage = $messageTextBox.Text
$password = $passwordTextBox.Text

if (-not [string]::IsNullOrEmpty($encryptedMessage) -and -not [string]::IsNullOrEmpty($password)) {
try {
$decryptedMessage = Decrypt-Message -EncryptedMessage $encryptedMessage -Password $password
$resultTextBox.Text = $decryptedMessage
} catch {
[System.Windows.Forms.MessageBox]::Show("Decryption failed. Check the message or password.", "Error")
}
} else {
[System.Windows.Forms.MessageBox]::Show("Please provide both an encrypted message and a password.", "Error")
}
})

# Show the Form
$form.ShowDialog()

2. Open the Notepad and Name the file > messageAES256.bat > save

@echo off
PowerShell -ExecutionPolicy Bypass -File .\messageAES256.ps1
pause

3. Double click on messageAES256.bat > ❤️ nostr.fmt.wiz.biz
Author Public Key
npub1ztnkkujxzr9thf7jmd04sfnd4wd79y88070r973tepesfmdesfjs6vds2y