From b2148f4a895db4b7fa010fb4064cf3ce35e3cd06 Mon Sep 17 00:00:00 2001 From: revsic Date: Mon, 18 Feb 2019 05:24:56 +0900 Subject: [PATCH] obfs, string: Update sample with make_table --- sample/string_obfs.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sample/string_obfs.cpp b/sample/string_obfs.cpp index 05a9410..1bb760b 100644 --- a/sample/string_obfs.cpp +++ b/sample/string_obfs.cpp @@ -3,11 +3,29 @@ #include template -constexpr char enc_xor(char c) { +constexpr char xor_(char c) { return c ^ key; } +template +constexpr char add(char c) { + return c + Key; +} + +template +constexpr char comp(char c) { + return f(g(c)); +} + int main() { - constexpr auto str = obfs::make_string, enc_xor<0x50>>("Hello World !"); + using table = obfs::make_table< + obfs::encoder_seq, add<10>, comp, add<10>>>, + obfs::decoder_seq, add<-10>, comp, xor_<0x50>>>>; + + std::cout << __TIME__ << std::endl; + std::cout << obfs::SEED << std::endl; + std::cout << obfs::RAND_VAL<__LINE__, 3> << std::endl; + + constexpr auto str = obfs::make_string("Hello World !"); std::cout << str.decode() << std::endl; } \ No newline at end of file