Results 1 to 2 of 2

Thread: Fast string byte manipulation

Threaded View

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Fast string byte manipulation

    For those of you new to strings and their ascii values, there's a very quick way to access their ascii value without using mid$ and the asc() function.

    You can also build an ascii byte array to transform it back into string.

    A simple, and very fast, encryption routine:

    VB Code:
    1. Dim BytAry() as Byte
    2. Dim mStr as String
    3. Dim x as Long
    4. mStr = "any string"
    5. 'convert VB's BSTR(unicode) to single ASCii values
    6. BytAry = StrConv(mStr,vbFromUnicode)
    7. 'dim encryption array
    8. ReDim EncAry(ubound(BytAry)) as Byte
    9. 'loop
    10. For x = 0 to ubound(BytAry)
    11.      'Xor values for a simple encryption
    12.      EncAry(x) = BytAry(x) Xor 255
    13. Next
    14. 'Convert ascii array to unicode array so VB can directly use a unicode byte array as a string
    15. MsgBox StrConv(EncAry,vbUnicode)

    Using this method several MBs can be processed instantly(when compiled).

    On my machine, Xp 1600+, 256 MB DDR, it does 35 MB/s.

    Processes 1 GB in barely over 29 seconds.
    Last edited by DiGiTaIErRoR; Sep 19th, 2003 at 01:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width