summaryrefslogtreecommitdiff
path: root/hex.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2002-10-04 17:31:41 +0000
committerweidai <weidai11@users.noreply.github.com>2002-10-04 17:31:41 +0000
commita3b6ece7ab341b5b14135baeccea7d5e4c086771 (patch)
tree8b045309c238226c32a563b1df6b9c30a2f0e0b3 /hex.h
downloadcryptopp-git-a3b6ece7ab341b5b14135baeccea7d5e4c086771.tar.gz
Initial revision
Diffstat (limited to 'hex.h')
-rw-r--r--hex.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/hex.h b/hex.h
new file mode 100644
index 00000000..9dba4dc6
--- /dev/null
+++ b/hex.h
@@ -0,0 +1,36 @@
+#ifndef CRYPTOPP_HEX_H
+#define CRYPTOPP_HEX_H
+
+#include "basecode.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! Converts given data to base 16
+class HexEncoder : public SimpleProxyFilter
+{
+public:
+ HexEncoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int outputGroupSize = 0, const std::string &seperator = ":", const std::string &terminator = "")
+ : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
+ {
+ IsolatedInitialize(MakeParameters("Uppercase", uppercase)("GroupSize", outputGroupSize)("Seperator", ConstByteArrayParameter(seperator)));
+ }
+
+ void IsolatedInitialize(const NameValuePairs &parameters);
+};
+
+//! Decode 16 bit data back to bytes
+class HexDecoder : public BaseN_Decoder
+{
+public:
+ HexDecoder(BufferedTransformation *attachment = NULL)
+ : BaseN_Decoder(GetDecodingLookupArray(), 4, attachment) {}
+
+ void IsolatedInitialize(const NameValuePairs &parameters) {}
+
+private:
+ static const int *GetDecodingLookupArray();
+};
+
+NAMESPACE_END
+
+#endif