Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-01

How to convert a large integer to base64

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andreas Schneider
to Frank Church
Frank Church wrote
Is there a FCL library that can be used to convert a large integer into base64 format?
Define  "large  integer"  ... in case you mean a normal integer/int64:
IntToHex(...);
Best Regards, Andreas
Frank Church
to Andreas Schneider: Define "large integer" ... in case you mean a normal integer/int64: IntToHex(...);…
Andreas Schneider wrote 10 lines
On Saturday, January 15, 2011 18:52 Frank Church wrote: > Is there a FCL library that can be used to convert a large integer into base64 format? Define "large integer" ... in case you mean a normal integer/int64: IntToHex(...);

I mean int64 into base64 encoding, as in the mime type.

Show quoted text 8 lines
-- Best Regards, Andreas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Frank Church ======================= http://devblog.brahmancreations.com
Andreas Schneider
to Frank Church
Frank Church wrote
I mean int64 into base64 encoding, as in the mime type.

Oops, my bad. Then yeah, as Henry said the base64 unit should help. Depending on who and how the number is to be decoded then, you could also take a which can convert from decimal
into any given number system. (... and the opposite Numb2Dec)

Best Regards, Andreas
Frank Church
to Henry Vermaak: Do you know about the base64 unit? Henry
Henry Vermaak wrote 8 lines
On 15 January 2011 17:52, Frank Church wrote: > > Is there a FCL library that can be used to convert a large integer into > base64 format? Do you know about the base64 unit?

I have it working now, but I have noticed that if the length of string is not a multiple of 3, it crashes.

Is there a way of adapting a string with a length that is not a multiple of 3 to allow it to encode, but yet
decode it back to the original string?

The other part is I want to pass the int64 in binary form.

Will a pointer to the integer and setting the length to copy to 8 be the right approach?

i.e

Encoder.CopyFrom(P^.Integer64Value, 8)

Of course the 8 will generate an error.

Henry

_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Frank Church ======================= http://devblog.brahmancreations.com