Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in signing with SHA256 #38

Open
ElyasNaranjeeSani opened this issue Dec 22, 2015 · 1 comment
Open

Problem in signing with SHA256 #38

ElyasNaranjeeSani opened this issue Dec 22, 2015 · 1 comment

Comments

@ElyasNaranjeeSani
Copy link

Hi,

First, thanks for your awesome tool.
I'm trying to sign a string with SHA256 as below.
,,,

NSData *messageData = [message dataUsingEncoding:NSUTF8StringEncoding];
NSData *signature = [[keyPair private] signWithSHA256:messageData error:&signingError];

,,,

There is no signing error and the signature variable in not nil.
I need the signature as a base64 encoded string but when I wanna convert the signature to string none of the below solutions works and all of them returns nil.

,,,

NSString *str1=[[NSString alloc]initWithData:signature encoding:NSUTF8StringEncoding];
NSString* str2 = [NSString stringWithUTF8String:(char *)[signature bytes]];
NSString* str3 = [NSString stringWithUTF8String:[signature bytes]];

,,,

Appreciate any help,
Thanks

@crono81
Copy link

crono81 commented Jul 13, 2018

Try:
NSLog(@"%@", [[NSString alloc] initWithData:[signature base64EncodedDataWithOptions:NSDataBase64EncodignEndLineWithLineFeed] encoding:NSUTF8StringEncoding]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants