|
-
May 27th, 2000, 12:36 AM
#1
Can someone explain the difference between :
Dim MyArray() as byte
and
Dim MyArray() as String * 1
I need to write a long string to an array, and I was wondering which type of array would be more suitable for rapid calculations.
This will be part of an Encryption DLL so i'll need testers later on if anyone is interested.
thanks.
-
May 27th, 2000, 01:48 AM
#2
Fanatic Member
When you say
Dim MyArray() as String * 1
any string you pass to your array will be cut off after the first character. Whereas, if you dim as byte you must pass a ascii number for the character between 0 and 255.
If you dim as string and then fix the width(as above) the string can be any length that you determine up to 64K(2^16 characters long). For example
dim mystring as string * 300
would return a fixed length string 300 characters long.
-
May 27th, 2000, 01:57 AM
#3
oops sorry
I think I didnt explain enough:
I want to have the long string spread over the entire array, IE. one character per element. I dont mind if i have to convert to numbers, just as long as its fast to run.
-
May 27th, 2000, 02:04 AM
#4
Frenzied Member
DON'T USE THE SECOND ONE.
I would use an array of longs and do the strings 4 characters at a time.
use copymemory to put the string into an array, then we're not using vb strings anymore. (vb strings are fairly slow)
(if 4 doesn't divide the length of your strings, ie you have a 9 letter string then use 3 longs to store it, you'll be left with 3 null characters at the end of your string when you decrypt it)
it'll take roughly as long to handle the long integer as it does the byte, but with the long you're handling 4 characters at once so it's nearly 4 times as fast.(probably not 4 in practice)
the strings will take longer, a string is actually a long pointer to an array of integers, to do a calculation with a string you have to look at the long pointer then look up the integer in question, so that's about half the speed of the byte.
-
May 27th, 2000, 02:04 AM
#5
Hyperactive Member
Find out for yourself; test both and time how long it takes to complete a phrase.
-
May 27th, 2000, 02:43 AM
#6
transcendental analytic
I would choose the byte array, it's faster as you use numeric calculations. Also I have a fast algoritm encryption sample and a key encryption on my homepage.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 27th, 2000, 04:11 AM
#7
Hyperactive Member
What is a purpose of doing this?
-
May 27th, 2000, 04:58 PM
#8
LG,
I am creating an encryption algorithm and using an array is the fastest way to do it. Now I need to know what sort of array is manipulated fastest by the CPU.
Sam,
I cant use the CopyMemory method because I am using VB to create the DLL, not C++.
Anyone:
How do I convert 3 or 4 characters into one Long value?
-
May 27th, 2000, 06:42 PM
#9
transcendental analytic
If you're reading or writing from a file you could probably use get and put with a long array. Also, i'm almost sure that integer is fastest, but byte allow me to encrypt strings directly with strconv convertion method
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 27th, 2000, 07:45 PM
#10
I'm giving up on this idea because I cant get the algorithm to decrypt properly.
-
May 27th, 2000, 08:19 PM
#11
transcendental analytic
Paste your algoritm here or send it to me and i'll have a look at what's wrong
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 27th, 2000, 11:22 PM
#12
well it works fine when encrypting, its just decrypting that screws up. there is no reason for this that I can see because all you have to do is run the encrypted text through the DLL again and that should be it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|