Taka has the honor of being credited with the most posts from a single submission. I'm sure that's little consolation considering how much money his company spent on this open source1 system, and how much effort it has taken to get it working. No less, today's code is the fourth (parts 1, 2, 3) and final piece from the encryption module.
Note that, before using these "binary math" functions, the module must convert first convert decimals into a hexadecimal string, and then convert the hex string into a binary string ...
Function Shiftbin(bin, places) 'left shift binary Shiftbin = _ Right(bin, Len(bin) - cint(places)) & _ Left(bin, cint(places)) End Function Function XORbin(bin1, bin2) ' eXclusive OR on two binaries Dim output, idx For idx = 1 To Len(bin1) Select Case Mid(bin1, CInt(idx), 1) Case Mid(bin2, CInt(idx), 1) output = output & "0" Case Else output = output & "1" End Select Next XORbin = output End Function Function ORbin(bin1, bin2) ' inclusive OR on two binaries Dim output, idx For idx = 1 To Len(bin1) If Mid(bin1, cint(idx), 1) = "1" Or _ Mid(bin2, cint(idx), 1) = "1" Then output = output & "1" Else output = output & "0" End If Next ORbin = output End Function Function ANDbin(bin1, bin2) ' AND function on two binaries Dim output, idx For idx = 1 To Len(bin1) If Mid(bin1, cint(idx), 1) = "1" And _ Mid(bin2, cint(idx), 1) = "1" Then output = output & "1" Else output = output & "0" End If Next ANDbin = output End Function Function NOTbin(bin) ' Swaps 1's and 0's of a given binary Dim output, idx For idx = 1 To Len(bin) If Mid(bin, cint(idx), 1) = "1" Then output = output & "0" Else output = output & "1" End If Next NOTbin = output End Function
1 Open Source as in, they paid more money to have a licence to look at and modify the source code.