monotone

monotone Mtn Source Tree

Root/botan/hex.h

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

Archive Download this file

Branches

Tags

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