1

I'm encrypting a string say "hello h r u" Using encryption algorithm and getting the encrypted String as b�*-ت5Tr���6=

This String we cannot send as an sms
So i want to convert to sms supported format by converting it into 7 bit.
and on the receiver side we have to convert back into 8 bit and decrypt.
How can i achieve this?

Note: I have used Base64 to convert into sms supported format but the length is increasing. So iam not able to send more character

Anil Kumar C
  • 1,604
  • 4
  • 22
  • 43
user1203673
  • 1,015
  • 7
  • 15
  • You ask 'how can I achieve this' - yet you then say you've successfully base 64 encoded it. So you've solved your problem, yes? Is your only problem the size increase due to the base 64 encoding? – Greg Kopff May 11 '12 at 05:35
  • yes i want size to not increase much – user1203673 May 11 '12 at 05:44
  • 2
    [Base 64 encoding has roughly a 33% overhead](http://en.wikipedia.org/wiki/Base64) - you've trying to encode the same data, but with less information density. You won't escape this. What's your actual question? – Greg Kopff May 11 '12 at 05:48
  • i want the size to not increase much and also the string has to be in sms supported format can we change the 8bit to 7 bit and send. is it possible if it is possible how can it be done – user1203673 May 11 '12 at 05:54
  • You are asking for base128. There are implementations available on google – Esben Skov Pedersen May 11 '12 at 06:16
  • You've got the solution - you need to encode the data using something like Base64. Read about Base64 encoding and you'll learn why you can't escape the character count increasing. – Greg Kopff May 11 '12 at 06:16
  • @EsbenSkovPedersen: relevant: http://stackoverflow.com/questions/6008047/why-dont-people-use-base128-in-javascript -- SMS uses a 7-bit character set. – Greg Kopff May 11 '12 at 06:18
  • 2
    Greg -> since sms is 7 bit it will match base128. In the event that sms 7 bit and base128 does not use the same chars, it is a simple matter of changing the letters used in an base128 implementation and making his own version of base128 – Esben Skov Pedersen May 11 '12 at 06:21
  • @EsbenSkovPedersen: actually - you're right - all the SMS alphabet is printable. – Greg Kopff May 11 '12 at 06:30

1 Answers1

0

I'm assuming your question is something like:

How can I transmit my binary data as valid SMS text without increasing the size of the message?

The answer for this is - you can't - at least not with 100% certainty.

Your encryption algorithm probably creates some byte array (byte[]) which will grow by around 33% (as stated in the above comments) once you Base64 encode it.

The only option I see is to attempt to compress the information either before or after encryption - depending on which compression algorithm you choose - and then Base64 encode it. This will give you a better chance of making the size limit - but nothing definitive. (Unless you find a compression algorithm which promises to compress by more than 33% for every input.

An alternative is to span the message over two SMS messages - assuming you are allowed to do that.

RonK
  • 9,472
  • 8
  • 51
  • 87