# Unit synacode

Description | uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables

## Description

Various encoding and decoding support

## uses

- SysUtils

## Overview

### Functions and Procedures

`function DecodeTriplet(const Value: AnsiString; Delimiter: AnsiChar): AnsiString;`
`function DecodeQuotedPrintable(const Value: AnsiString): AnsiString;`
`function DecodeURL(const Value: AnsiString): AnsiString;`
`function EncodeTriplet(const Value: AnsiString; Delimiter: AnsiChar; Specials: TSpecials): AnsiString;`
`function EncodeQuotedPrintable(const Value: AnsiString): AnsiString;`
`function EncodeSafeQuotedPrintable(const Value: AnsiString): AnsiString;`
`function EncodeURLElement(const Value: AnsiString): AnsiString;`
`function EncodeURL(const Value: AnsiString): AnsiString;`
`function Decode4to3(const Value, Table: AnsiString): AnsiString;`
`function Decode4to3Ex(const Value, Table: AnsiString): AnsiString;`
`function Encode3to4(const Value, Table: AnsiString): AnsiString;`
`function DecodeBase64(const Value: AnsiString): AnsiString;`
`function EncodeBase64(const Value: AnsiString): AnsiString;`
`function DecodeBase64mod(const Value: AnsiString): AnsiString;`
`function EncodeBase64mod(const Value: AnsiString): AnsiString;`
`function DecodeUU(const Value: AnsiString): AnsiString;`
`function EncodeUU(const Value: AnsiString): AnsiString;`
`function DecodeXX(const Value: AnsiString): AnsiString;`
`function DecodeYEnc(const Value: AnsiString): AnsiString;`
`function UpdateCrc32(Value: Byte; Crc32: Integer): Integer;`
`function Crc32(const Value: AnsiString): Integer;`
`function UpdateCrc16(Value: Byte; Crc16: Word): Word;`
`function Crc16(const Value: AnsiString): Word;`
`function MD5(const Value: AnsiString): AnsiString;`
`function HMAC_MD5(Text, Key: AnsiString): AnsiString;`
`function MD5LongHash(const Value: AnsiString; Len: integer): AnsiString;`
`function SHA1(const Value: AnsiString): AnsiString;`
`function HMAC_SHA1(Text, Key: AnsiString): AnsiString;`
`function SHA1LongHash(const Value: AnsiString; Len: integer): AnsiString;`
`function MD4(const Value: AnsiString): AnsiString;`

### Types

`TSpecials = set of AnsiChar;`

### Constants

`SpecialChar: TSpecials = ['=', '(', ')', '[', ']', '<', '>', ':', ';', ',', '@', '/', '?', '\', '"', '_'];`
`NonAsciiChar: TSpecials = [#0..#31, #127..#255];`
`URLFullSpecialChar: TSpecials = [';', '/', '?', ':', '@', '=', '&', '#', '+'];`
`URLSpecialChar: TSpecials = [#$00..#$20, '_', '<', '>', '"', '%', '{', '}', '|', '\', 'ˆ', '˜', '[', ']', '`', #$7F..#$FF];`
`TableBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';`
`TableBase64mod = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,=';`
`TableUU = '`!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]ˆ_';`
`TableXX = '+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';`
`ReTablebase64 = #$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$3E +#$40 +#$40 +#$40 +#$3F +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$00 +#$01 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40;`
`ReTableUU = #$01 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$3E +#$3F +#$00 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40;`
`ReTableXX = #$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$00 +#$40 +#$01 +#$40 +#$40 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$3E +#$3F +#$40 +#$40 +#$40 +#$40 +#$40 +#$40;`

## Description

### Functions and Procedures

`function DecodeTriplet(const Value: AnsiString; Delimiter: AnsiChar): AnsiString;`

Decodes triplet encoding with a given character delimiter. It is used for decoding quoted-printable or URL encoding.

`function DecodeQuotedPrintable(const Value: AnsiString): AnsiString;`

Decodes a string from quoted printable form. (also decodes triplet sequences like '=7F')

`function DecodeURL(const Value: AnsiString): AnsiString;`

Decodes a string of URL encoding. (also decodes triplet sequences like '%7F')

`function EncodeTriplet(const Value: AnsiString; Delimiter: AnsiChar; Specials: TSpecials): AnsiString;`

Performs triplet encoding with a given character delimiter. Used for encoding quoted-printable or URL encoding.

`function EncodeQuotedPrintable(const Value: AnsiString): AnsiString;`

Encodes a string to triplet quoted printable form. All NonAsciiChar are encoded.

`function EncodeSafeQuotedPrintable(const Value: AnsiString): AnsiString;`

Encodes a string to triplet quoted printable form. All NonAsciiChar and SpecialChar are encoded.

`function EncodeURLElement(const Value: AnsiString): AnsiString;`

Encodes a string to URL format. Used for encoding data from a form field in HTTP, etc. (Encodes all critical characters including characters used as URL delimiters ('/',':', etc.)

`function EncodeURL(const Value: AnsiString): AnsiString;`

Encodes a string to URL format. Used to encode critical characters in all URLs.

`function Decode4to3(const Value, Table: AnsiString): AnsiString;`

Decode 4to3 encoding with given table. If some element is not found in table, first item from table is used. This is good for buggy coded items by Microsoft Outlook. This software sometimes using wrong table for UUcode, where is used ' ' instead '`'.

`function Decode4to3Ex(const Value, Table: AnsiString): AnsiString;`

Decode 4to3 encoding with given REVERSE table. Using this function with reverse table is much faster then Decode4to3. This function is used internally for Base64, UU or XX decoding.

`function Encode3to4(const Value, Table: AnsiString): AnsiString;`

Encode by system 3to4 (used by Base64, UU coding, etc) by given table.

`function DecodeBase64(const Value: AnsiString): AnsiString;`

Decode string from base64 format.

`function EncodeBase64(const Value: AnsiString): AnsiString;`

Encodes a string to base64 format.

`function DecodeBase64mod(const Value: AnsiString): AnsiString;`

Decode string from modified base64 format. (used in IMAP, for example.)

`function EncodeBase64mod(const Value: AnsiString): AnsiString;`

Encodes a string to modified base64 format. (used in IMAP, for example.)

`function DecodeUU(const Value: AnsiString): AnsiString;`

Decodes a string from UUcode format.

`function EncodeUU(const Value: AnsiString): AnsiString;`

encode UUcode. it encode only datas, you must also add header and footer for proper encode.

`function DecodeXX(const Value: AnsiString): AnsiString;`

Decodes a string from XXcode format.

`function DecodeYEnc(const Value: AnsiString): AnsiString;`

decode line with Yenc code. This code is sometimes used in newsgroups.

`function UpdateCrc32(Value: Byte; Crc32: Integer): Integer;`

Returns a new CRC32 value after adding a new byte of data.

`function Crc32(const Value: AnsiString): Integer;`

return CRC32 from a value string.

`function UpdateCrc16(Value: Byte; Crc16: Word): Word;`

Returns a new CRC16 value after adding a new byte of data.

`function Crc16(const Value: AnsiString): Word;`

return CRC16 from a value string.

`function MD5(const Value: AnsiString): AnsiString;`

Returns a binary string with a RSA-MD5 hashing of "Value" string.

`function HMAC_MD5(Text, Key: AnsiString): AnsiString;`

Returns a binary string with HMAC-MD5 hash.

`function MD5LongHash(const Value: AnsiString; Len: integer): AnsiString;`

Returns a binary string with a RSA-MD5 hashing of string what is constructed by repeating "value" until length is "Len".

`function SHA1(const Value: AnsiString): AnsiString;`

Returns a binary string with a SHA-1 hashing of "Value" string.

`function HMAC_SHA1(Text, Key: AnsiString): AnsiString;`

Returns a binary string with HMAC-SHA1 hash.

`function SHA1LongHash(const Value: AnsiString; Len: integer): AnsiString;`

Returns a binary string with a SHA-1 hashing of string what is constructed by repeating "value" until length is "Len".

`function MD4(const Value: AnsiString): AnsiString;`

Returns a binary string with a RSA-MD4 hashing of "Value" string.

### Types

`TSpecials = set of AnsiChar;`

### Constants

`SpecialChar: TSpecials = ['=', '(', ')', '[', ']', '<', '>', ':', ';', ',', '@', '/', '?', '\', '"', '_'];`

`NonAsciiChar: TSpecials = [#0..#31, #127..#255];`

`URLFullSpecialChar: TSpecials = [';', '/', '?', ':', '@', '=', '&', '#', '+'];`

`URLSpecialChar: TSpecials = [#$00..#$20, '_', '<', '>', '"', '%', '{', '}', '|', '\', 'ˆ', '˜', '[', ']', '`', #$7F..#$FF];`

`TableBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';`

`TableBase64mod = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,=';`

`TableUU = '`!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]ˆ_';`

`TableXX = '+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';`

`ReTablebase64 = #$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$3E +#$40 +#$40 +#$40 +#$3F +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$00 +#$01 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40;`

`ReTableUU = #$01 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$3E +#$3F +#$00 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40;`

`ReTableXX = #$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$00 +#$40 +#$01 +#$40 +#$40 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$3E +#$3F +#$40 +#$40 +#$40 +#$40 +#$40 +#$40;`

Generated by PasDoc 0.9.0 on 2012-04-23 21:38:52