Advertisement
gnamp

DM encrypt decrypt 1

Dec 1st, 2012
3,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'basic encrypt/decrypt by Dominic McGough 1/12/2012
  2. start:
  3. TextWindow.Write("Encrypt [e] or decrypt [d]?: ")
  4. choice = TextWindow.Read()
  5.  
  6. If choice = "e" Then
  7.   encryptedString = ""
  8.   TextWindow.Write("Enter the original string to encrypt: ")
  9.   unencryptedString = TextWindow.Read()
  10.   For i = 1 To Text.GetLength(unencryptedString)
  11.     unencryptedArray[i] = Text.GetSubText(unencryptedString,i,1)
  12.     encryptedArray[i] = Text.GetCharacterCode(unencryptedArray[i])+2
  13.     encryptedString = Text.Append(encryptedString,Text.GetCharacter(encryptedArray[i]))
  14. EndFor
  15.   TextWindow.WriteLine(encryptedString)
  16. Else
  17.   decryptedString = ""
  18.   TextWindow.Write("Enter the encrypted string to decrypt: ")
  19.   preencryptedString = TextWindow.Read()
  20.   For i = 1 To Text.GetLength(preencryptedString)
  21.     preencryptedArray[i] = Text.GetSubText(preencryptedString,i,1)
  22.     decryptedArray[i] = Text.GetCharacterCode(preencryptedArray[i])-2
  23.   decryptedString = Text.Append(decryptedString,Text.GetCharacter(decryptedArray[i]))
  24. EndFor
  25. TextWindow.WriteLine(decryptedString)
  26. 'For i = 1 To Text.GetLength(preencryptedString)
  27.  
  28.  
  29. EndIf
  30. TextWindow.Write("Do you wish to go again?: ")
  31. again = TextWindow.Read()
  32. If again = "y" Then
  33.   Goto start
  34. Else
  35.   Program.End()
  36.   EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement