This is a simple demonstration on how to encrypt data for your game. If you want to use this to encrypt data for your game then expand on it to make it a bit harder to crack
.
Global Name as String : Name = "HeavyAmp"
Global EncryptName as String
EncryptName = EncryptData(Name)
Name = RestoreData(EncryptName)
Print Name,"=",EncryptName
Wait Key
End
Function EncryptData(StringData as String)
`Get the Length of Our Data
Local Length as Integer
Length=Len(StringData)
`Create an Array to hold all the charcters of our String
Dim Char(Length) as String
`Seperate the String Data into seperate Characters in an array
For aChar=1 to Length
Char(aChar) = MID$(StringData,aChar)
Next aLetter
Local ChangeData as Integer
`Encrypt the Data by subtracting the ASCII data for each Chracter by 10
For aChar=1 to Length
ChangeData=Asc(Char(aChar))-10
Char(aChar)=Chr$(ChangeData)
Next aLetter
`Recombine our character array back into one string
StringData = ""
For aChar=1 to Length
StringData = StringData + Char(aChar)
Next aLetter
EndFunction StringData
Function RestoreData(StringData as String)
`Get the Length of Our Data
Local Length as Integer
Length=Len(StringData)
`Create an Array to hold all the charcters of our String
Dim Char(Length) as String
`Seperate the String Data into seperate Characters in an array
For aChar=1 to Length
Char(aChar) = MID$(StringData,aChar)
Next aLetter
Local ChangeData as Integer
`Restore the Data by Adding the ASCII data for each Chracter by 10
For aChar=1 to Length
ChangeData=Asc(Char(aChar))+10
Char(aChar)=Chr$(ChangeData)
Next aLetter
`Recombine our character array back into one string
StringData = ""
For aChar=1 to Length
StringData = StringData + Char(aChar)
Next aLetter
EndFunction StringData
Zotoaster's/Kaedroho's Improved Version:
Global Name as String
Global EncryptName as String
input "Type the text which you want to encrypt-->",Name
EncryptName = EncryptData(Name)
Name = RestoreData(EncryptName)
Print Name,"=",EncryptName
Wait Key
End
Function EncryptData(StringData as String)
Local Encrypted as String
For Char = 1 to len(StringData)
Encrypted = Encrypted + chr$( asc( mid$( StringData, Char ) ) - 10 )
Next Char
EndFunction Encrypted
Function RestoreData(StringData as String)
Local Decrypted as String
For Char = 1 to len(StringData)
Decrypted = Decrypted + chr$( asc( mid$( StringData, Char ) ) + 10 )
Next Char
EndFunction Decrypted
Better to be dead, than to live your life afraid.