Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bitwise Operations
Message
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00671926
Message ID:
00671983
Views:
14
Nigel,

>I need to create an object to wrap around the Crypto API and am having trouble converting an existing object (VFP).

There is a number of Crypto API wrapper on sites like www.planet-source-code.com. You can also download a CAPICOM from MS site.

>Does anybody know how I can right- or left- shift bits?

The author of this code is Fredrik Qvarfort:
Private Function lBSL(ByRef lInput As Long, ByRef bShiftBits As Byte) As Long
  
  lBSL = (lInput And (2 ^ (31 - bShiftBits) - 1)) * 2 ^ bShiftBits
  If (lInput And 2 ^ (31 - bShiftBits)) = 2 ^ (31 - bShiftBits) Then lBSL = (lBSL Or &H80000000)

End Function
Private Function lBSR(ByRef lInput As Long, ByRef bShiftBits As Byte) As Long
  
  If (bShiftBits = 31) Then
    If (lInput < 0) Then lBSR = &HFFFFFFFF Else lBSR = 0
  Else
    lBSR = (lInput And Not (2 ^ bShiftBits - 1)) \ 2 ^ bShiftBits
  End If

End Function

Private Function lBSRU(lInput As Long, bShiftBits As Byte) As Long
  
  If (bShiftBits = 31) Then
    lBSRU = -(lInput < 0)
  Else
    lBSRU = (((lInput And Not (2 ^ bShiftBits - 1)) \ 2 ^ bShiftBits) And Not (&H80000000 + (2 ^ bShiftBits - 2) * 2 ^ (31 - bShiftBits)))
  End If

End Function
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform