I'm referring to the code here: http://www.blitzbasic.com/codearcs/codearcs.php?code=1711
1) What does type does '@@ Ptr' refer to? (noel's code)
2) I'm going to be encrypting pixmap pixel data (byte ptr), can I just use bytes in the encryption instead of shorts? (referring to outbuf@@ ptr)
This is what I've conjured up so far.. don't know what to do next.
EDIT: Wait a sec.. Since this is using a ptr, should I even bother returning a copy of the data? Instead change it to just modify the block of memory? (It isn't necessary for the image to be intact afterwards, as I will just be loading in a new pixmap after encrypting and sending the data out)
And how would I get the size of the data after encryption? (seeing as width*height*4 wont work, the encryption should raise the size IIRC)
1) What does type does '@@ Ptr' refer to? (noel's code)
2) I'm going to be encrypting pixmap pixel data (byte ptr), can I just use bytes in the encryption instead of shorts? (referring to outbuf@@ ptr)
This is what I've conjured up so far.. don't know what to do next.
Function RC4_Bytes:Byte Ptr(inp:Byte Ptr, count:Int, key:String) If inp = Null Then Return Null Local S:Int[512 + Ceil(count *.55)] Local i:Int, j:Int, t:Int, X:Int Local outbuf@@ Ptr = Short Ptr(Varptr s[512]) j = 0 For i = 0 To 255 S[i] = i If j > (key.Length - 1) Then j = 0 EndIf S[256 + i] = key[j] & $ff j:+1 Next j = 0 For i = 0 To 255 j = (j + S[i] + S[256 + i] ) & $ff t = S[i] S[i] = S[j] S[j] = t Next i = 0 j = 0 For Local X:Int = 0 To count - 1 i = (i + 1) & $ff j = (j + S[i] ) & $ff t = S[i] S[i] = S[j] S[j] = t t = (S[i] + S[j] ) & $ff outbuf[X] = (inp[X] ~ S[t] ) Next Return String.FromShorts(outbuf, count) 'What should I be doing here? if shorts are the fastest to use End Function
EDIT: Wait a sec.. Since this is using a ptr, should I even bother returning a copy of the data? Instead change it to just modify the block of memory? (It isn't necessary for the image to be intact afterwards, as I will just be loading in a new pixmap after encrypting and sending the data out)
And how would I get the size of the data after encryption? (seeing as width*height*4 wont work, the encryption should raise the size IIRC)