I need some help, I have a function in B4A which does basic ASCII shift on a string input. I use this function to do a basic encryption on my data. My PHP knowledge is very poor and having tried multiple times I am not able to get the below function converted to PHP.
I would appreciate if someone could convert the below into PHP
B4A Function:
Sub AsciiSwitch(InputString As String, ValueToAdd As Int) As String
Dim OutputString As String
OutputString=""
Dim c As Char
For i = 0 To InputString.Length - 1
c = InputString.CharAt(i)
OutputString = OutputString & Chr(Asc(c) + ValueToAdd)
Next
Return OutputString
End Sub
Please note that what you're doing is using a Caesar cipher, which Julius Caesar used some time around 50BC. To say it's insecure is an understatement. If you're using this to hide information from small children, it's probably fine, but you might want to read up on other alternatives on encryption here in the forum for all other uses. I believe I've seen some solution where there's also a matching piece of php code to use.
Please note that what you're doing is using a Caesar cipher, which Julius Caesar used some time around 50BC. To say it's insecure is an understatement. If you're using this to hide information from small children, it's probably fine, but you might want to read up on other alternatives on encryption here in the forum for all other uses. I believe I've seen some solution where there's also a matching piece of php code to use.
This example is based on agrahams encryption library: Encryption Lib 1. Generate a 32 byte pw (just call the sub) and store it 2. Encrypt the data by calling AES_Encrypt. Return is a byte array or a base64 encoded string 3. Salt is a random value which is added at the beginning of the encrypted...