monotone

monotone Mtn Source Tree

Root/botan/hex.h

1/*************************************************
2* Hex Encoder/Decoder Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_HEX_H__
7#define BOTAN_HEX_H__
8
9#include <botan/filter.h>
10
11namespace Botan {
12
13/*************************************************
14* Hex Encoder *
15*************************************************/
16class Hex_Encoder : public Filter
17 {
18 public:
19 enum Case { Uppercase, Lowercase };
20 static void encode(byte, byte[2], Case = Uppercase);
21
22 void write(const byte[], u32bit);
23 void end_msg();
24
25 Hex_Encoder(Case);
26 Hex_Encoder(bool = false, u32bit = 72, Case = Uppercase);
27 private:
28 void encode_and_send(const byte[], u32bit);
29 static const byte BIN_TO_HEX_UPPER[16];
30 static const byte BIN_TO_HEX_LOWER[16];
31
32 const Case casing;
33 const u32bit line_length;
34 SecureVector<byte> in, out;
35 u32bit position, counter;
36 };
37
38/*************************************************
39* Hex Decoder *
40*************************************************/
41class Hex_Decoder : public Filter
42 {
43 public:
44 static byte decode(const byte[2]);
45 static bool is_valid(byte);
46
47 void write(const byte[], u32bit);
48 void end_msg();
49
50 Hex_Decoder(Decoder_Checking = NONE);
51 private:
52 void decode_and_send(const byte[], u32bit);
53 void handle_bad_char(byte);
54 static const byte HEX_TO_BIN[256];
55
56 const Decoder_Checking checking;
57 SecureVector<byte> in, out;
58 u32bit position;
59 };
60
61}
62
63#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status