Last active
January 12, 2021 18:31
-
-
Save Arnaud-Chevalier/eb3ed7b4e3a4a25f4a1eba279a408827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################### | |
#Encrypt | |
################### | |
#Message to encrypt | |
$text = "titi a cru voir un grosminet" | |
#Shift number | |
$i = 3 | |
#Transform the text to an array of ascii | |
$asciis = [int[]][char[]]"$text" | |
#Add the shift specified to every ascii character | |
$encrypt = foreach ($ascii in $asciis) { | |
$ascii + $i | |
} | |
#Transform back the ascii to text | |
$asciitotext = [char[]]$encrypt | |
#Transform the array to a string to read it easily | |
$arraytostring = -join $asciitotext | |
$arraytostring | |
################### | |
#Decrypt | |
################### | |
$text = "wlwl#d#fux#yrlu#xq#jurvplqhw" | |
#Shift number | |
$i = 3 | |
#Transform the text to an array of ascii | |
$asciis = [int[]][char[]]"$text" | |
#Add the shift specified to every ascii character | |
$decrypt = foreach ($ascii in $asciis) { | |
$ascii - $i | |
} | |
#Transform back the ascii to text | |
$asciitotext = [char[]]$decrypt | |
#Transform the array to a string to read it easily | |
$arraytostring = -join $asciitotext | |
$arraytostring |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment