Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Which Language is good?

Status
Not open for further replies.

pnnavigator0915

Member level 3
Joined
Feb 4, 2006
Messages
62
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,900
Hey Guys,
I have my project in cryptography involving implementation of the Secret Key, Public Key and Hash Algorithms (2 Each) in a programming language.

Well, I see that there is a lot of bit swizzling and playing with bits involved in the implementation. I started up with MATLAB but that's a kind of easy tool, anyone can do it.. I've already completed implementing DES.

But i want some better implementation..
Like C or C++ or Perl or may be Delphi or C#..

I don't know.. which one to choose.. Well, not much i can choose, coz i just know C. But I really want to use C++ or Perl. But i cant find useful functions that can handle, swizzle, swap and play around with the bits as can be done easily in MATLAB.

Can anyone help me with this?..
If someone knows how to better handle bits of data (more precisely input file) individually and concatenating them to words and Dwords... Please, help me with that..

Thanks.
Regards.
PNNAVIGATOR
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
I think if you already know C language C++ will not be difficult just you must learn about oriented object notion if you have to use it. So I thnik C++ or C# are a great choise.

It may exist a way to call Matlab function from a C++ program I think it must be something like that just look at commands such as Mux or mbuild in Matlab it may indicates you something
 

pnnavigator0915

Member level 3
Joined
Feb 4, 2006
Messages
62
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,900
jakjoud said:
I think if you already know C language C++ will not be difficult just you must learn about oriented object notion if you have to use it. So I thnik C++ or C# are a great choise.

It may exist a way to call Matlab function from a C++ program I think it must be something like that just look at commands such as Mux or mbuild in Matlab it may indicates you something
That's right man.. You know what I'm gonna go with C++. I dunno about calling a Matlab Function.. But if you have some idea about how do I handle a single bit in C++, that'd be great.

What do you think, is there a function available in C++ that'd allow me to permute the bits of a given Byte or DWord?

Thanks, dude.
Regards.
PNNAVIGATOR
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
I'm not very sure of what you mean by permute the bits of a given Byte or DWord but if you want to make some operations on the bits positions why not program your own functions??
 

_TopGun_

Member level 4
Joined
Aug 20, 2005
Messages
75
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,288
Location
Zelenograd, Russian Federation
Activity points
1,696
Operating with single bits in byte (or any other data type) is not very difficult.
You can use operators "&" and "|" to manipulate bits and also you can create an union to access single bits.
 

pnnavigator0915

Member level 3
Joined
Feb 4, 2006
Messages
62
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,900
jakjoud said:
I'm not very sure of what you mean by permute the bits of a given Byte or DWord but if you want to make some operations on the bits positions why not program your own functions??
By permutation I mean, if the input word length is say 32 bits to a permute function.

Then the positions of all the bits will be changed as per the function.
Say the first bit will be 23rd, 2nd bit will be 31st, 3rd bit will be 18th and so on.. not a proper sequence.. a random sequence as it is in DES first and final permutation step..

Also if I have a byte how do I extract exactly first and last two bits and calculate the corresponding nibble???
That's what is bugging me!..

But if you find something do post..

Thanks.
Regards.
Pnnavigator
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
So for the second question in a byte to extract the first and the last two bits you can just multply your byte by :
11000000 for having the first two buts and 00000011 for the last ones.

Let me ask you for the first problem the function you need make the same random sequence every time you make a call? so you have your first word(wj for j=1..32) and an output word (oj j=1..32) and a word where you can make operation (pj j=1..32). I'll try to explain for the first case 1st bit==>23rd:

p=0;
o=w*2^31
for i=1: 22
o=/2; // Everytime the bit oj is translated to oj-1
p=p+0; // binary sum

hence you have the first case.
If there is any other problem don't feel bother to ask about
 

irfansyah

Advanced Member level 4
Joined
Dec 29, 2004
Messages
106
Helped
9
Reputation
18
Reaction score
1
Trophy points
1,298
Location
New South Wales
Activity points
1,128
jakjoud said:
So for the second question in a byte to extract the first and the last two bits you can just multply your byte by :
11000000 for having the first two buts and 00000011 for the last ones.
Yes, and for the first two bits you might need to shift it some bits. I havent program in C for years, but i think there are bit manipulation operators, shouldn't there? Pls have a look at this site for an example: http://www.phim.unibe.ch/comp_doc/c_manual/C/CONCEPT/bitwise.html
 

jhbbunch

Full Member level 4
Joined
Feb 21, 2006
Messages
199
Helped
17
Reputation
34
Reaction score
3
Trophy points
1,298
Activity points
2,902
Or you could just write it in java and use its built in cryptography class.
 

Darth Maul

Junior Member level 1
Joined
Jul 19, 2007
Messages
18
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Location
Yogyakarta, Indonesia
Activity points
1,436
there's bit operators like &, |, ^, >>, <<, ~, right? you can use these operators to manipulate individual bit(s) in a single byte. you can use unsigned char type to represent a single byte to be manipulated, or an array of it for multiple bytes. i think i've seen some codes similar to your needs, give me some time.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top