Håber virkelig der er en der har forstand på udvikling af Apps.
Jeg er ved at lave et login og det gør jeg ved at sende data til en url og tjekker om tallet 1 kommer frem - Så er man logget ind.. Det virker helt fint, men jeg ønsker at sha512 min password string
Jeg ved bare ikke hvordan! Jeg har googlet dette og fundet frem til det her:
Min funktion:
- + (NSString *) createSHA512:(NSString *)source {
-
- const char *s = [source cStringUsingEncoding:NSASCIIStringEncoding];
-
- NSData *keyData = [NSData dataWithBytes:s length:strlen(s)];
-
- uint8_t digest[CC_SHA512_DIGEST_LENGTH] = {0};
-
- CC_SHA512(keyData.bytes, keyData.length, digest);
-
- NSData *out = [NSData dataWithBytes:digest length:CC_SHA512_DIGEST_LENGTH];
-
- return [out description];
- }
Og her jeg gerne vil encode min password string
- - (void) loginAction{
-
- if ([userNameTextField.text isEqualToString:@""] || [passwordTextField.text isEqualToString:@""]) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Please Fill all the field" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- [alert show];
- return;
- }
- // i will use a code from connect to DB tutorial
- NSString *strURL = [NSString stringWithFormat:@"http://localhost/iblogging/engine/index.php?function=login&email=%@&pass=%@",userNameTextField.text, passwordTextField.text];
-
- // to execute php code
- NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
-
- // to receive the returend value
- NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
-
- if ([strResult isEqualToString:@"1"])
- {
- // i need to get the control for main navigation controller
- AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
- [appDelegate.navigationController popToRootViewControllerAnimated:NO];
- // create object from app main view to push it
- AppMainView *appMainView = [[AppMainView alloc] initWithNibName:@"AppMainView" bundle:nil];
- [appDelegate.navigationController pushViewController:appMainView animated:YES];
- }else
- {
- // invalid information
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Invalide Information" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- [alert show];
- return;
-
- }
- }