How do the AND and Or keywords behave in ASP when comparing numbers?

I need to convert old authentication code from ASP to PHP. In the code that is used to encrypt / decrypt passwords, I came across lines like this

Char2 = Mid(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1)

      

I am really curious how to translate code like this, especially how to deal with the part (number and number).

+3


source to share


1 answer


Unfortunately, there is no easy way to convert this without wasting time. There is a neat tool you can use here ... but you will need to read the comments in the converted code as it will tell you there are assumptions such as UDFs that are not defined .. from there you will need to write your own or try to understand this is.



But, to directly answer your question, these are bitwise operations and can be done like Byte2 & 240

+4


source







All Articles