troubleshooting error in array substring

sunarto.gouw

Member
Joined
May 22, 2013
Messages
12
Programming Experience
Beginner
hello, can someone help me in this error:

        Dim input As String = txtpassword.Text
        Dim w = Array.CreateInstance(GetType(Integer), New Integer() {133}, New Integer() {-8})
        Dim a As Double = -8
        Dim b As Integer = 0
        Dim c As Integer = 4






        Do While a <= 0
            w(a) = (input.Substring(b, c))
            MsgBox(w(a))
            a += 1
            b += 4
            c += 4
        Loop


when i input letter, it says "Invalid cast exception was unhandled. Conversion from string "asdf" to type 'Integer' is not valid."
please help
 
Last edited by a moderator:
You're creating an Integer array and you're trying to assign a String to one of the elements. I'm not sure why it would be a surprise that that doesn't work. Do you actually want an Integer array or a String array?

Also, is there a specific reason that you are creating an array with a lower bound of -8? There's nothing in your code that suggests it's required.
 
so, how to write the code?
i need an array in negative 8
thats for serpent encryption algorithm i working on right now

and how to do "PADDING"? padding in serpent algorithm is "short keys with less than 256 bits are mapped to full-length keys of 256 bits by appending one "1" bit to the MSB end, followed by as many "0" bits as required to make up 256 bits."

then i need to separate the 256 bits key into 8 32 bits and put it into array.

i really don't know how.

thanks for your replies
 
Soooo... maybe you should learn to do that instead of trying to make something you know nothing about work properly? Trying to run before learning to walk here friend...

Padding refers to adding zeros at the beginning or the end. In this case, you append it before the most significant bit. Is it little- or big- endian?

How many bits in a byte? How many bytes in 256 bits?

Cryptography is maths, pure and simple... If you are having trouble with padding and block extraction, you will have EXTREME difficulty understanding how the block cipher applies to the data. You should really go back and read a bit more....
 
Back
Top