Objective-c creation of PublicKey -


will (anyone) please let me know how create publickey using modulus , exponent(only 2 values whatever have).

in java simple.

rsapublickeyspec spec = new rsapublickeyspec(modulus, publicexponent); keyfactory factory = keyfactory.getinstance("rsa");                                                                                publickey pub = factory.generatepublic(spec); 

i want know how done in objective-c.

i managed achieve same using ideawu rsa libraies, had issues encoding of public key libraries assume need footer , headers in key (i.e. begin public key , end public key) , don't url encode result required, modified 1 of methods , worked, perfectly:

+ (nsstring *)encryptstring:(nsstring *)str publickey:(nsstring *)pubkey{      nsdata *decodeddata = [[nsdata alloc] initwithbase64encodedstring:pubkey options:0];     nsstring *decodedkey = [[nsstring alloc] initwithdata:decodeddata encoding:nsutf8stringencoding];     decodedkey = [decodedkey stringbyreplacingoccurrencesofstring:@"-----begin public key-----\n" withstring:@""];     decodedkey = [decodedkey stringbyreplacingoccurrencesofstring:@"-----end public key-----" withstring:@""];      nsdata *data = [rsa encryptdata:[str datausingencoding:nsutf8stringencoding] publickey:decodedkey];     nsstring *ret = base64_encode_data(data);     ret = [ret stringbyaddingpercentencodingwithallowedcharacters:[nscharacterset alphanumericcharacterset]];     return ret; } 

besides that, library easy import , compiled without warnings or errors.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -