Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
Google keywords:
sha1 mac os x
md5 mac os x

If those results aren't what you want, then please be more specific. For example, what programming language?

We can't read your mind to understand the context of your question. Nor can we always assume that your latest question is a follow-up to one of your previous questions.

http://www.cocoadev.com/index.pl?HowToAskQuestions

http://www.mikeash.com/getting_answers.html

After reading those, you might want to bookmark this page:
http://www.cocoadev.com/index.pl

and use it to search CocoaDev for keywords like sha1 or md5.
 

Detrius

macrumors 68000
Sep 10, 2008
1,623
19
Apex, NC
Try:

% man 3 SHA1

It should give you something that looks somewhat like this:

http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man3/SHA1.3ssl.html

Code:
        #include <openssl/sha.h>

        unsigned char *SHA1(const unsigned char *d, unsigned long n,
                         unsigned char *md);


% man 3 md5

http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man3/md5.3ssl.html

Code:
        #include <openssl/md5.h>

        unsigned char *MD5(const unsigned char *d, unsigned long n,
                         unsigned char *md);


So basically, the function names are "SHA1" and "MD5."




...and hope to god you don't have to do the same thing on Windows.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
I tried to Google for that, but I couldn't find what I wanted.

I'm using Objective-C. I want to hash strings using SHA1 with a RSA key hash strings with MD5. I'm on Snow Leopard with Xcode 3.2.1.

Then try googling with something else that might be more relevant. For example, the computer language you're writing in, or the framework you're using. Like:
sha1 objective c
sha1 cocoa


And also try searching the cocoadev site, using the URL I gave previously.
 

Detrius

macrumors 68000
Sep 10, 2008
1,623
19
Apex, NC
It gives you BINARY (20 bytes == 160 bits). It's not a string to be printed. I don't know if NSLog handles all of printf's format strings, but "%x" is how you tell printf you want your 32-bit integer to display as hexadecimal.

see:

% man 3 printf
 

Detrius

macrumors 68000
Sep 10, 2008
1,623
19
Apex, NC
Then try googling with something else that might be more relevant. For example, the computer language you're writing in, or the framework you're using. Like:
sha1 objective c
sha1 cocoa


And also try searching the cocoadev site, using the URL I gave previously.

In doing your search, you must have realized that all of this is in the OpenSSL library on the Mac. Search developer sites, search library sites, and SEARCH MAN PAGES (apropos).
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
Still no luck :(

I'll repeat my earlier suggestion when you were asking about license-registration software:
Read the source of Aquatic Prime.

If you don't understand what it's doing, then you need to get to the point where you do.

You need to know the fundamentals perfectly. If you can't figure out how to call a C function, then you need to work on that before trying something more complex.

You also need to post your code. "Still no luck" is not debuggable. It's not even compilable.

http://whathaveyoutried.com/
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
Tried this for MD5:

unsigned char *MD5(const unsigned char *d, unsigned long n,
unsigned char *md);

That only declares a function. It doesn't produce any code.

In fact, it looks exactly like the declaration of openssl's MD5 function, as provided by its man page (man 3 md5).

#include <openssl/md5.h>

unsigned char *MD5(const unsigned char *d, unsigned long n,
unsigned char *md);

void MD5_Init(MD5_CTX *c);
void MD5_Update(MD5_CTX *c, const void *data,
unsigned long len);
void MD5_Final(unsigned char *md, MD5_CTX *c);

We need to see your code. The code that defines your variables and then calls openssl's MD5 function.
 

fernandovalente

macrumors 6502
Original poster
#import <openssl/md5.h>


-(IBAction)generate:(id)sender{
unsigned char *MD5(const unsigned char *d, unsigned long n,
unsigned char *md);

int MD5_Init(MD5_CTX *c);
int MD5_Update(MD5_CTX *c, const void *data,
unsigned long len);
int MD5_Final(unsigned char *md, MD5_CTX *c);
}

I want to set a value to be encrypted and get the value it returns.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
I'm still studding them. :/
--signature--
iPhone Stuff: Radio Tool X MoneyMaker X Chiaro Tic Tac Toe Chiaro Sortion

This doesn't add up. You appear to be shipping four iPhone apps, yet you don't know how to call a C function? Or didn't you write those four iPhone apps?

If you didn't write the apps, and you don't know C, then you should probably pick a simpler project than an uncrackable license-key enforcement system.

My only intent is to be honest about this, not nasty, but it looks like you don't have the necessary skills at this time.
 

fernandovalente

macrumors 6502
Original poster
This doesn't add up. You appear to be shipping four iPhone apps, yet you don't know how to call a C function? Or didn't you write those four iPhone apps?

If you didn't write the apps, and you don't know C, then you should probably pick a simpler project than an uncrackable license-key enforcement system.

My only intent is to be honest about this, not nasty, but it looks like you don't have the necessary skills at this time.

Yes, I wrote the four apps you see in my signature. 100% of the code was wrote by me. Believe or not, I'm a C n00b. I know more about C++ than I know about C. I know Objective-C(I'm not an expert), but I don't know C yet. I will start studding C soon. I don't wanna write an uncrackable license-key enforcement system, but a decent one. :/
 

fernandovalente

macrumors 6502
Original poster
I found the problem. Call me idiot, I deserve it. I read the documentation only once. I thought they were variables. I know you're gonna laugh and say I'm an idiot, I really deserve it. I guess I need to pay more attention at thing I read. Sorry guys. :(
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Yes, I wrote the four apps you see in my signature. 100% of the code was wrote by me. Believe or not, I'm a C n00b. I know more about C++ than I know about C. I know Objective-C(I'm not an expert), but I don't know C yet. I will start studding C soon. I don't wanna write an uncrackable license-key enforcement system, but a decent one. :/

Seeing as Objective-C is a superset of C then by definition if you know Objective-C you also know C.

The only thing I can suggest is that you work on both your Objective-C and C skills. This is all fundamental stuff we are talking about here.
 

fernandovalente

macrumors 6502
Original poster
Seeing as Objective-C is a superset of C then by definition if you know Objective-C you also know C.

The only thing I can suggest is that you work on both your Objective-C and C skills. This is all fundamental stuff we are talking about here.

Sorry for all posts made on this thread. I really need to pay more attention at thing I read. Yes, I know about Objective-C being a superset of C. I'm working on them. I'm learning something new each day. :)
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Sorry for all posts made on this thread. I really need to pay more attention at thing I read. Yes, I know about Objective-C being a superset of C. I'm working on them. I'm learning something new each day. :)

Don't get me wrong. People on this site are very willing to help but you need to phrase your questions correctly to get the help that you want. You also need to show what you have done yourself otherwise people will assume you are trying to freeload.

Keep reading and keep asking and you'll get there soon enough :).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.