Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Base64 encode issue #3

Closed
transaction opened this issue Apr 14, 2015 · 6 comments
Closed

Base64 encode issue #3

transaction opened this issue Apr 14, 2015 · 6 comments

Comments

@transaction
Copy link

Hi, back with another issue, base64 encoding sometimes gives invalid output, for example: FsYAyq8KfCz5B41dRDqxuZR8xhvFuAKZE7nWDn3MrnCRYio8wj0PYeNDD1u4G/Bj36fjPWMUzx+CZfSjZhOaHMBC7cnbw0D5JrN2RDLFHQC5C7Mkw7I1Oq2mf5byDl+ayHHAGHqv8Ztj4zBuBJX4v1ZF48BGW+mNiiQWtiFBVODbL6Qu56Do1iyaoRaStRKwtd9mppdmmZJWa8YTtt7+9Q1yB07IRan+Qg5kUku8AmRLp9nNZ3k1/60pv+V7nPp7CkYWIZ3ASNQOVMRbsjoiEfmPlipuZtLLVqJTLY8xGaFuKSvQ5Ibdj0GUkycWbZYbe8T4KaFyk55qlapyUsFArw==ar=grego

The characters after == shouldn't be there, but there is data stored in them since it also doesn't work if I remove them.

Any fixes/workarounds available? My C skills are terrible so I'm at a loss here. Different encoding (hex for example) would also be ok.

Other example: Pi/+a+8kPNZRZk4Mm+vjniOmUMzE67/69P7/vP/pySJ4QFWWpVSSSEQuX+LB+vCF85neGbJ2fp4DYuZFI0eZyo382zCThxEAjmATUAXmAz4ZgopQkQVv9MHPTVzbRecDcY1t+AeiyhhHhXzNl4U2e0xYrEgnZcrZXE8/YfmoPgr2yeBNfIRQE2BFLXNZRGZUZkdzbjrhmouBclgv7mN37SPZr0gj8VSSbKzOM5ElGKuw4joc9iIJhG5x99Z617STNkbXg5KgHbFLs9/rrafd6obHkiLltmFqsaw/MNgkpm7YrIKaa2XxlUkiNE5EOp37A7snsKlJpa3HBGDPom+D1Q==µ∫Âfl›öQ'

@jslim89
Copy link
Owner

jslim89 commented Apr 20, 2015

Have you test with the php script? Just copy the output from console, then test it with php script. See if it works

@amccague
Copy link

Can confirm there is an issue with the base64 encode, a test of 100,000 attempts to encrypting a string using a public key gave a maximum of 2714 attempts before the output was not (null).

Changing the code to return the unsigned char * and its length, creating an NSData object from that and returning a base64 encoded string was our solution.

@transaction
Copy link
Author

@amccague Thanks for confirming. Could you post the relevant code changes please?

@jslim89
Copy link
Owner

jslim89 commented Apr 21, 2015

@amccague You may submit a pull request here. Thanks

@Lakshmi2012
Copy link

Can any one help me on the same issue. Public Encrypt is retuning nil. If any one has the fixed code snippet please share me.

Thanks,
Lakshmi

@jslim89
Copy link
Owner

jslim89 commented Dec 1, 2015

Merged a pull request #12

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

No branches or pull requests

4 participants