Possible encoding type to convert a byte array to be sent by SMS
I need to send a public key created by RSA by SMS to another phone.开发者_运维知识库 I am converting the 148 byte public key to base64 to be sent by SMS. But it increases the 148 bytes to 200 bytes when converted.
As byte[] cannot be directly sent by SMS, what are the other possible methods of converting them successfully to strings or equivalent which can be sent through SMS? Other than compressing, is base64 the only possible method?
You can an SMS in 8bit mode - most GSM modems and gateways have this option, and some phones also expose this capability in their API.
This way you can send the entire key, and still have 12 bytes for extra data. You'll need some software on the phone which will be able read the message and use it, though.
Another option: send it in two related separate SMSes; most(?) phones know how to send and combine separate SMSes to one logical message (to understand how it exactly works you'll have to dig into the SMS protocol specifications).
Adamk mentioned binary mode for sending SMS. Unfortunately this still leaves you with only 140 bytes for the payload, 8 bytes short!
If the target application is able to handle concatenated messages and it's acceptable that each key sent costs twice as much, then you should go with this solution.
精彩评论