Results 1 to 7 of 7
  1. #1
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8

    Array problem

    Sorry I am really new to this VBA..

    I need to enter 256 integer values(hexadecimal numbers) into an array I tried doing this..

    Dim SB() As Integer


    SB()= 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01,...
    (so many values)................0x0F, 0xB0, 0x54, 0xBB, 0x16.

    If in any programming language declaring would be like such..
    int a[]={0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01,...
    (so many values)................0x0F, 0xB0, 0x54, 0xBB, 0x16.}

    But VBA does not allow me to use { or it does not even allow me to use 0x.. it says End of expression requiered.. please help me to get this array problem sorted..

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Two questions (and much more)

    1) Why do you need a hexadecimal array for Access? (no answer necessary)
    2) What are you really trying to do? Fill an array with a set of numbers in particular order? Fill an array with numbers between 1 and 256 in random order? Why can't you simply fill the array with integers? Or do you need the hexadecimal equivalent as a string?

  3. #3
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8
    okay.. let me explain... All i need is to perform an AES encryption.. i need to encrypt a field and store it in the batabase..as the user types the data in a form it needs to be passed on to a VBA module and AES encryption needs to be performed to that data and stored in the database.. is there any other way around performing the encryption?

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I believe that you can encrypt the entire database. However, I don't

    recall any of the particulars. Is that a possibility?

    Here is brute force, non-syntax checked, non-debugged code that should randomly fill the SB array with a complete set of numbers between 1 and 256.

    dim SB (1 to 256) as integer
    dim BS (1 to 256) as integer
    dim X as integer
    dim N as integer
    ' Fill an array
    For x = 1 to 256
    BS(x) = X
    loop
    ' now fill out the other array with random values
    N = 1
    do While N <= 256
    x = 255.0 * rnd + 1
    If BS(X) > 0 then
    SB(N) = BS(X)
    BS(X) = 0
    N = N +1
    end if
    loop

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by dbdvl View Post
    okay.. let me explain... All i need is to perform an AES encryption..
    Encrypting field data in access requires mathematics, written in visual basic. Don't think there's a way around that. Visual basic doesn't have, for instance, hash functions like MD5 or Sha1 like web languages do.

    I assume you've read this: http://en.wikipedia.org/wiki/Advance..._the_algorithm

    Or know what it means? Hope so!

    So what do hex values have to do with this process? If you're looking for a mathematics script that will do the encryption of a field value, hex values are irrelevant. I don't think you can write literal hex values in ANY platform. The purpose of any given programming language and its operating platform is to allow users to type something closer to English words so they don't have to figure out which combinations of bitwise blocks will work for executing an application. That's what compilers are for.


    dim SB (1 to 256) as integer
    dim BS (1 to 256) as integer
    dim X as integer
    dim N as integer
    ' Fill an array
    For x = 1 to 256
    BS(x) = X
    loop
    ' now fill out the other array with random values
    N = 1
    do While N <= 256
    x = 255.0 * rnd + 1
    If BS(X) > 0 then
    SB(N) = BS(X)
    BS(X) = 0
    N = N +1
    end if
    loop
    Not really quite sure what that is??? The person wanted mathematics for encryption, not random array elements. Isn't that what it is?

  6. #6
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8

    Thanks Adam..

    Yes.. I am trying to perform AES encryption.. if you look in depth of how AES works you will know that it performs the various stages of transformations for every round(this happens for 10 rounds) the link you provided is just the basic.. I needed this Hex array because in the round SubBytes (http://en.wikipedia.org/wiki/Rijndael_S-box), KeyExpansion (http://en.wikipedia.org/wiki/Rijndael_key_schedule)it involves a hex array.. in java or other programming language the hex value can be determined by adding a 0X in front of it.. infact I have already implemented such encryption algorithm in Java but not in VB.. unfortunately.. Access supports only VB.. so i needed to know how to enter those values..

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by dbdvl View Post
    infact I have already implemented such encryption algorithm in Java but not in VB.. unfortunately.. Access supports only VB.. so i needed to know how to enter those values..
    I would venture to guess that if you posted the logic that you wrote in Java, you may just see a vb version of it popup in this thread. Or if not that, and explanation of how to do it (or why it can't be done).

    by the way, hex value denotes in vb have some options:

    1)the HEX() function returns hex values for numerical string entered. however, it does not support the alphas in base-16. It also uses the same random scheme that table sorting does (it is not consistent with return values). It may be a character-weighting issue, AGAIN. Thus, it's not useful.

    2) Hex values can be interpreted by vb preceeding a value denotation with an "&H". "&H" is the literal for hex interpretation. Hence: &HFF = 255 in vb.
    Last edited by ajetrumpet; 12-03-2011 at 03:14 PM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Array will not ReDim...
    By yeah in forum Programming
    Replies: 1
    Last Post: 10-08-2011, 06:30 PM
  2. Load SQL results into an array
    By Tyork in forum Programming
    Replies: 8
    Last Post: 01-24-2011, 01:58 PM
  3. can i put the result in array?
    By dada in forum Programming
    Replies: 1
    Last Post: 08-19-2010, 07:17 PM
  4. Building Array
    By jgelpi16 in forum Forms
    Replies: 12
    Last Post: 03-22-2010, 12:33 PM
  5. How to use array? [ solved] Thanks.
    By wasim_sono in forum Programming
    Replies: 0
    Last Post: 10-20-2006, 12:00 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
  •  
Other Forums: Microsoft Office Forums