SmOke_N

Cipher Rot1 - Rot25 and Rot47

4 posts in this topic

#1 ·  Posted (edited)

I needed this today ( two different Rot ciphers/cyphers ), so I decided to go ahead with Rot1 - Rot25 and Rot47.

Example (Run from SciTe to see output):

#include "cipherRot.au3"

Global $gs_Original = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Global $gs_Encode = ""
For $i = 1 To 25 ; notice decode param used with 1-4, 6-12, 14-17, 19-25
    $gs_Encode = _cipher_Rot($gs_Original, $i)
    ConsoleWrite("Rot" & $i & @TAB & "Encode: " & $gs_Encode & @CRLF)
    ConsoleWrite("Rot" & $i & @TAB & "Decode: " & _cipher_Rot($gs_Encode, $i, True) & @CRLF)
    ConsoleWrite("----" & @CRLF & @CRLF)
Next

$gs_Encode = _cipher_Rot($gs_Original, 47)
ConsoleWrite("Rot47" & @TAB & "Encode: " & $gs_Encode & @CRLF)
ConsoleWrite("Rot47" & @TAB & "Decode: " & _cipher_Rot($gs_Encode, 47) & @CRLF)
ConsoleWrite("----" & @CRLF & @CRLF)

cipherRot.au3

2015-01-10 cipherRot.au3

Edited by SmOke_N
1 person likes this

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites



Interesting. I've seen functions in the AutoIt Snippets section for ROT13 and ROT47, but not the rest. Thanks.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Fixed issue with Rot 1-4, 6-12, 14-17, and 19-25, had to add a decode param for those.

1 person likes this

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Excellent :)  Just what I need.

A nice effectively simple encode :D


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • iamtheky
      By iamtheky
      Hopefully this expands as I get to play more with Neo4j.  Starting simple here is an example of mapping artists to the bands they are in (a not quite complete Puscifer visualization).
       

       
       
      ;2DArray TO Neo4j #include<array.au3> Local $aBandMaster[0] ; declare this array fo later Local $aArray[1][2] ; declare this array for right....now $aArray[0][0] = "name" ;Title of column 1, will also be the Property of the NODEs established by the elements in this column $aArray[0][1] = "is_member_of" ;Title of column 2, will also be the Relationship of the items in column 1 to those in column 2 $Property = $aArray[0][0] ; Using 0,0 as property $Relationship = $aArray[0][1] ; using 0,1 as relationship ;creating a 2D array with semicolon as the delimiter between the NAME (The Property) ; IS_MEMBER_OF (The Relationship) ;(The Relationship) for this example, is a comma delimited list of the bands that the person IS_MEMBER_OF _ArrayAdd($aArray , "Jeff;Puscifer,APC,EODM,TBM,CarinaRound,Filter" , 0 , ";") _ArrayAdd($aArray , "MJK;Puscifer,APC,Tool" , 0 , ";") _ArrayAdd($aArray , "MattMc;Puscifer,EODM,TBM" , 0 , ";") _ArrayAdd($aArray , "Carina;Puscifer,CarinaRound" , 0 , ";") _ArrayAdd($aArray , "MatMit;Puscifer" , 0 , ";") _ArrayAdd($aArray , "Paul;Puscifer,Ministry" , 0 , ";") _ArrayAdd($aArray , "Mahsa;Puscifer,Omniflux" , 0 , ";") ;~ _ArrayDisplay($aArray) ; Mira! it is the array we just created $sOutStr = "Create" & @LF ;sOutStr will be the running catchall for the command we eventually want to run in Neo4j For $i = 1 to ubound($aArray) - 1 $sOutStr &= "(" & $aArray[$i][0] & ":Person {" & $Property & ": '" & $aArray[$i][0] & "'})," & @LF ; as we are looping through, use column one to create NODES that are PERSONS (this is assumed unique, if not you should get on that) _ArrayAdd($aBandMaster , stringsplit($aArray[$i][1] , "," , 2)) ; also while looping split all the comma delimited strings in column 2 and make one big list of bands stored in $aBandMaster ;~ _ArrayDisplay($aBandMaster , "BandMaster") Next $aBands = _ArrayUnique($aBandMaster) ; unique that master list and now we have a nice list of all of the bands from everyones list ;~ _ArrayDisplay($aBands , "unique bands") For $k = 1 to $aBands[0] $sOutStr &= "(" & $aBands[$k] & ":Band {" & $Property & ": '" & $aBands[$k] & "'})," & @LF ;roll through that list once creating NODES, one for each BAND Next For $i = 1 to ubound($aArray) - 1 $aPersonalBands = stringsplit($aArray[$i][1] , "," , 2) ; second loop, only this time we are building relationships, so we are working only off of the comma separated list for each individual For $k = 0 to ubound($aPersonalBands) - 1 $sOutStr &= "(" & $aArray[$i][0] & ")-[:" & $Relationship & "]->(" & $aPersonalBands[$k] & ")," & @LF ;Since those NODES were created above, we know their names and can build RELATIONSHIPS Next Next consolewrite(stringtrimright($sOutstr , 2) & @LF) ; This should be able to copy/paste directly into Neo4j ; match n optional match (n)-[r]-() return n, r; ; you need to run this afterward in Neo4j for the visualization  
       
    • guinness
      By guinness
      Maybe other ideas will follow.


      using System; using System.Collections.Generic; namespace Rot13 { internal class Program { public static void Main() { Rot13 rot13 = new Rot13(); // Create a rotation 13 object. string encodedString = rot13.Encode("Rotate this string."); // Encode the string. Console.WriteLine("Encoded string: {0}", encodedString); string decodedString = rot13.Decode(encodedString); // Decode the rotated string. Console.WriteLine("Decoded string: {0}", decodedString); Console.WriteLine(""); // Create a new line. Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } public class Rot13 { private Dictionary<char, char> rot13 = new Dictionary<char, char>(); /// <summary> /// Initialise the dictionary on a per object basis. I guess it could be made static as well?! /// </summary> public Rot13() { string lowLower = "abcdefghijklm", highLower = "nopqrstuvwxyz"; string lowUpper = "ABCDEFGHIJKLM", highUpper = "NOPQRSTUVWXYZ"; for (int i = 0; i < lowUpper.Length; i++) { // Convert a => n and A => N. rot13.Add(lowLower[i], highLower[i]); rot13.Add(highLower[i], lowLower[i]); // Convert n => a and N => A. rot13.Add(lowUpper[i], highUpper[i]); rot13.Add(highUpper[i], lowUpper[i]); } } /// <summary> /// Decode a Rot13 string. /// </summary> /// <param name="data">A Rot13 encoded string.</param> /// <returns>The original string.</returns> public string Decode(string data) { return Encode(data); } /// <summary> /// Encode a string to using Rot13. /// </summary> /// <param name="data">A string to be encoded.</param> /// <returns>An encoded string.</returns> public string Encode(string data) { char rotated = new char(); char[] array = data.ToCharArray(); for (int i = 0; i < array.Length; i++) { if (rot13.TryGetValue(array[i], out rotated)) { array[i] = rotated; } } return new string(array); } } }
    • DeltaRocked
      By DeltaRocked
      Hope this helps someone.


      $string = 'Hello World' $string=Rot47($string) MsgBox(0, 'Encode', $string) $string=Rot47($string) MsgBox(0, 'Decode', $string) Func Rot47($input) Local $rotted, $i=1 While $i <= StringLen($input) $pos = StringMid($input, $i, 1) If Asc($pos) + 47 >= 127 And Asc($pos) > 32 And Asc($pos) < 127 Then $rotted &= Chr(Asc($pos) - 47) ElseIf Asc($pos) + 47 <= 126 And Asc($pos) > 32 And Asc($pos) < 127 Then $rotted &= Chr(Asc($pos) + 47) Else $rotted &= $pos EndIf $i += 1 WEnd Return $rotted EndFunc ;==>Rot47