Thread Subject: Hexadecimal matrices

Subject: Hexadecimal matrices

From: Alissa gotenberg

Date: 3 May, 2007 17:01:11

Message: 1 of 7

hello all , hope every thing is fine ,
i need help as usual :-) ,

i was working on the Advanced Encryption Standard , but i suddenly
stopped at the point that i have to create a matrix of hexadecimal
elemnts such that '0f' , 'A3' and so on , but unfortunatly the
matlab reads A3 as string not a hexa numbre , and the puts the 'A'
and the '3' in diferent columns in the matrix , which made a huge
mess in the program .

i tried the hex2dec() and dec2hex() but it will be a biiiiig overhead
, so i wanted to know if there is a way to treat 'A3' as hexa numbre
not as string and then i will be able to create a matrix of
hexadeciml values ,

sorry for taking long but the problem is big for me .

waiting for reply , and thanks in advance .
Alissa .

Subject: Hexadecimal matrices

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 3 May, 2007 22:01:50

Message: 2 of 7

In article <ef55c6c.-1@webcrossing.raydaftYaTP>,
Alissa Gotenberg <fete7a_85@hotmail.com> wrote:
>i was working on the Advanced Encryption Standard , but i suddenly
>stopped at the point that i have to create a matrix of hexadecimal
>elemnts such that '0f' , 'A3' and so on , but unfortunatly the
>matlab reads A3 as string not a hexa numbre , and the puts the 'A'
>and the '3' in diferent columns in the matrix , which made a huge
>mess in the program .

>i tried the hex2dec() and dec2hex() but it will be a biiiiig overhead
>, so i wanted to know if there is a way to treat 'A3' as hexa numbre
>not as string and then i will be able to create a matrix of
>hexadeciml values ,

Could you clarify (perhaps a small example) how you are
creating the matrix of hexadecimal elements? Are you reading
it from an outside file? Coding it in assignment statements?

If you are reading from a text file, then you could use a %x
format for the read.
--
  If you lie to the compiler, it will get its revenge. -- Henry Spencer

Subject: Hexadecimal matrices

From: Alissa gotenberg

Date: 3 May, 2007 20:31:49

Message: 3 of 7

Walter Roberson wrote:
> Could you clarify (perhaps a small example) how you are
> creating the matrix of hexadecimal elements? Are you reading
> it from an outside file? Coding it in assignment statements?
>
> If you are reading from a text file, then you could use a %x
> format for the read.
> --
> If you lie to the compiler, it will get its revenge. -- Henry
> Spencer
>

HI AGAIN WALTER,how are things :)

look the hex elemnts i'll are supposed to be constantly stored in the
memo as the program will use many times , like the S-Boxes and so on
,

and the is another matrix i take as input from the user , but no i
dont read from file ,

the onlye solution i found to store those values in matrix is to put
them in this form :-

Matrix=[(AAAB);
        (AC0F)];

this is the only way i found to store elemnts AA , AB , AC , 0F in
matrix , but as i said before this way treats the hexas as strings ,
and this is what i dont want .

so im looking for any way i can represent a matrix of hexadecimal
values ,
hope u got it , and help me .

thnx alot ,
Alissa.

Subject: Hexadecimal matrices

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 4 May, 2007 02:50:09

Message: 4 of 7

In article <ef55c6c.-1@webcrossing.raydaftYaTP>,
Alissa Gotenberg <fete7a_85@hotmail.com> wrote:
>i was working on the Advanced Encryption Standard

If this is the same project that you needed the pseudo-random
number generator for, then please note that the default
'twister' rand() pseudo-random generator has *not* been
certified as safe for cryptography. If this is of concern to you,
you might find this article by Jon Callas to be useful:

Using and Creating Cryptographic-Quality Random Numbers
http://www.merrymeet.com/jon/usingrandom.html
--
  "It is important to remember that when it comes to law, computers
  never make copies, only human beings make copies. Computers are given
  commands, not permission. Only people can be given permission."
                                               -- Brad Templeton

Subject: Hexadecimal matrices

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 4 May, 2007 03:59:21

Message: 5 of 7

In article <ef55c6c.1@webcrossing.raydaftYaTP>,
Alissa Gotenberg <fete7a_85@hotmail.com> wrote:

>look the hex elemnts i'll are supposed to be constantly stored in the
>memo as the program will use many times , like the S-Boxes and so on
>and the is another matrix i take as input from the user , but no i
>dont read from file ,

>the onlye solution i found to store those values in matrix is to put
>them in this form :-

>Matrix=[(AAAB);
> (AC0F)];

>this is the only way i found to store elemnts AA , AB , AC , 0F in
>matrix , but as i said before this way treats the hexas as strings ,
>and this is what i dont want .

Matrix = {'AA','AB'; 'AC', '0F'};
MatrixDec = uint8(reshape(hex2dec(Matrix),size(Matrix)));

--
  Prototypes are supertypes of their clones. -- maplesoft

Subject: Hexadecimal matrices

From: Alissa gotenberg

Date: 4 May, 2007 12:40:51

Message: 6 of 7

>
> Matrix = {'AA','AB'; 'AC', '0F'};
> MatrixDec = uint8(reshape(hex2dec(Matrix),size(Matrix)));
>
> --
> Prototypes are supertypes of their clones. -- maplesoft
>

no this is not the pesudo random project , this is somthing else ,

and about that representation i guess it treats the elments as
characters not hexa numbers ,

i guess i reached a dead end and i'll never be able to deal with them
as hexas :(

Subject: Hexadecimal matrices

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 4 May, 2007 17:26:54

Message: 7 of 7

In article <ef55c6c.4@webcrossing.raydaftYaTP>,
Alissa Gotenberg <fete7a_85@hotmail.com> wrote:

>> Matrix = {'AA','AB'; 'AC', '0F'};
>> MatrixDec = uint8(reshape(hex2dec(Matrix),size(Matrix)));

>and about that representation i guess it treats the elments as
>characters not hexa numbers ,

>i guess i reached a dead end and i'll never be able to deal with them
>as hexas :(

Matrix is in character form; MatrixDec is in 8-bit binary form,
suitable for arithmetic manipulation. The conversion would only
have to be done once, all at the same time, so this should be
fairly efficient.

--
  Is there any thing whereof it may be said, See, this is new? It hath
  been already of old time, which was before us. -- Ecclesiastes

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com