हे सब, मैं वर्तमान में एक संकलन-समय स्ट्रिंग एन्क्रिप्शन लिखने की कोशिश कर रहा हूं (शब्द 'स्ट्रिंग' और 'एन्क्रिप्शन' शब्द का उपयोग करके काफी हद तक) lib।वैराइडिक टेम्पलेट्स के साथ संकलन-समय 'स्ट्रिंग' मैनिपुलेशन
// Cacluate narrow string length at compile-time
template <char... ArgsT>
struct CountArgs
{
template <char... ArgsInnerT> struct Counter;
template <char Cur, char... Tail>
struct Counter<Cur, Tail...>
{
static unsigned long const Value = Counter<Tail...>::Value + 1;
};
template <char Cur>
struct Counter<Cur>
{
static unsigned long const Value = 1;
};
static unsigned long const Value = Counter<ArgsT...>::Value;
};
// 'Encrypt' narrow string at compile-time
template <char... Chars>
struct EncryptCharsA
{
static const char Value[CountArgs<Chars...>::Value + 1];
};
template<char... Chars>
char const EncryptCharsA<Chars...>::Value[CountArgs<Chars...>::Value + 1] =
{
Chars...
};
हालांकि मैं समझ नहीं कैसे पात्रों पर कार्रवाई करने के रूप में मैं उन्हें स्थिर सरणी में विस्तार:
मैं अब तक क्या किया है इस प्रकार है। मैं बस प्रत्येक चरित्र पर एक सरल ऑपरेशन निष्पादित करना चाहता हूं (उदा। '(((सी^0x12)^0x55) + 1)' जहां सी चरित्र है)।
सही दिशा में एक झुकाव की सराहना की जाएगी।
धन्यवाद सब कुछ।
आप एक दे सकता है उदाहरण के लिए ऊपर दिए गए कार्यों के साथ आप इसका उपयोग कैसे करना चाहते हैं? – David
चार const const * const pfooEnc = EncryptCharsA <'F','o','o'> :: मान; – RaptorFactor