21 #ifndef COSA_VIGENERE_HH 22 #define COSA_VIGENERE_HH 47 for (uint8_t i = 0; i < n; i++)
62 for (i = 0; i < N && password[i]; i++)
63 m_key[i] = password[i];
85 char res = c + m_key[m_nr++];
86 if (m_max != N) m_key[m_max++] = c;
87 if (m_nr == N) m_nr = 0;
98 for (
char* bp = (
char*) buf; n--; bp++)
108 void encrypt(
void* dest,
const void* src,
size_t n)
110 char* dp = (
char*) dest;
111 const char* sp = (
const char*) src;
112 while (n--) *dp++ =
encrypt(*sp++);
122 char res = c - m_key[m_nr++];
123 if (m_max != N) m_key[m_max++] = res;
124 if (m_nr == N) m_nr = 0;
135 for (
char* bp = (
char*) buf; n--; bp++)
145 void decrypt(
void* dest,
const void* src,
size_t n)
147 char* dp = (
char*) dest;
148 const char* sp = (
const char*) src;
149 while (n--) *dp++ =
decrypt(*sp++);
Vigenere(const char *password)
void encrypt(void *dest, const void *src, size_t n)
void encrypt(void *buf, size_t n)
uint32_t random(uint32_t range)
void decrypt(void *buf, size_t n)
Vigenere(uint32_t seed, uint8_t n=N)
void decrypt(void *dest, const void *src, size_t n)