# unsigned chars

- Thread: https://externals.io/message/47783
- Original archive: https://news-web.php.net/php.internals/47783
- Started by donald sullivan on 2010-04-05T09:01:11+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #47783 — donald sullivan — 2010-04-05T09:01:11+00:00

URL: https://externals.io/message/47783#47783

Hello,

is it possible to return unsigned chars from an extension?
I have looked and cant find anything on it, or maybe i am looking for the wrong keywords.

Thanks

ps i sent this to the general list on accident. i am not trying to flood the list.

---

## #47784 — Alexey Zakhlestin — 2010-04-05T09:10:50+00:00

URL: https://externals.io/message/47783#47784 · In reply to: #47783

> is it possible to return unsigned chars from an extension?
> I have looked and cant find anything on it, or maybe i am looking for the wrong keywords.

Return to PHP-code?

No. PHP doesn't have explicitly signed or unsigned chars. PHP has "strings"
you can return:
1) string of chars
2) int (array of ints?)

Also, see http://docs.php.net/ord
 `ord()` function converts first byte of byte-string to it's unsigned numeric representation

---

## #47785 — Alexey Zakhlestin — 2010-04-05T09:31:03+00:00

URL: https://externals.io/message/47783#47785

Use "reply all" when writing to mailing-list.




> what i am trying to do is RSA encryption
> 
> I have a working setup doing encryption and decryption at the same time. i want to store the encrypted value and be able to decrypted it later
> 
> if i encrypt the data and send the data straight to the decrypt function it works fine
> 
> int decryptRetVal = RSA_public_decrypt(512, Buffer, plainText, rsaPubKey, RSA_PKCS1_PADDING);
> 
> if i try to send the output of the encryption to the php side for storage, or even write it to a file and then read that file for decryption it fails every time
> 
> int decryptRetVal = RSA_public_decrypt(512, (unsigned char *)Z_STRVAL(zret), plainText, rsaPubKey, RSA_PKCS1_PADDING);
> 
> how can i store the encrypted output for later use?

well, it should work
you don't give details, so I can't say what are you doing wrong.

I can give you only generic debugging advices:
make sure that the data you store on php-side is equivalent to the data you expect to get on C-level.
If it is not — try to locate the step which corrupts the data, etc.
