1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
/**
* PasswordMaker - Creates and manages passwords
* Copyright (C) 2005 Eric H. Jung and LeahScape, Inc.
* http://passwordmaker.org/
* grimholtz@yahoo.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESSFOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Written by Miquel Burns <miquelfire@gmail.com> and Eric H. Jung
*/
#include <string.h>
#include "stdafx.h"
#include "leet.h"
using namespace std;
// Unless we make an Array class, we can only do this with
static const char *levels[][26] = {
{"4", "b", "c", "d", "3", "f", "g", "h", "i", "j", "k", "1",
"m", "n", "0", "p", "9", "r", "s", "7", "u", "v", "w", "x",
"y", "z"},
{"4", "b", "c", "d", "3", "f", "g", "h", "1", "j", "k", "1",
"m", "n", "0", "p", "9", "r", "5", "7", "u", "v", "w", "x",
"y", "2"},
{"4", "8", "c", "d", "3", "f", "6", "h", "'", "j", "k", "1",
"m", "n", "0", "p", "9", "r", "5", "7", "u", "v", "w", "x",
"'/", "2"},
{"@", "8", "c", "d", "3", "f", "6", "h", "'", "j", "k", "1",
"m", "n", "0", "p", "9", "r", "5", "7", "u", "v", "w", "x",
"'/", "2"},
{"@", "|3", "c", "d", "3", "f", "6", "#", "!", "7", "|<", "1",
"m", "n", "0", "|>", "9", "|2", "$", "7", "u", "\\/", "w",
"x", "'/", "2"},
{"@", "|3", "c", "|)", "&", "|=", "6", "#", "!", ",|", "|<",
"1", "m", "n", "0", "|>", "9", "|2", "$", "7", "u", "\\/",
"w", "x", "'/", "2"},
{"@", "|3", "[", "|)", "&", "|=", "6", "#", "!", ",|", "|<",
"1", "^^", "^/", "0", "|*", "9", "|2", "5", "7", "(_)", "\\/",
"\\/\\/", "><", "'/", "2"},
{"@", "8", "(", "|)", "&", "|=", "6", "|-|", "!", "_|", "|(",
"1", "|\\/|", "|\\|", "()", "|>", "(,)", "|2", "$", "|", "|_|",
"\\/", "\\^/", ")(", "'/", "\"/_"},
{"@", "8", "(", "|)", "&", "|=", "6", "|-|", "!", "_|", "|{",
"|_", "/\\/\\", "|\\|", "()", "|>", "(,)", "|2", "$", "|",
"|_|", "\\/", "\\^/", ")(", "'/", "\"/_"}
};
/**
* Convert the string in _message_ to l33t-speak
* using the l33t level specified by _leetLevel_.
* l33t levels are 0-8 with 0 being the simplest
* form of l33t-speak and 8 being the most complex.
*
* Note that _message_ is converted to lower-case if
* the l33t conversion is performed. To maintain
* backwards compatibility, do not change this function
* so it uses mixed-case.
*
* Using a _leetLevel_ <= 0 results in the original message
* being returned.
*
*/
string leetConvert(int level, string message)
{
string ret;
char *string;
int item;
if (level > -1 && level < 9) {
// ret = tolower(message);
ret = "";
string = (char *)message.c_str();
// Unless a better to lower is known to me, use this for now
for (item = 0; item < (int)strlen(string); item++) {
string[item] = tolower(string[item]);
}
for (item = 0; item < (int)strlen(string); item++) {
if (string[item] >= 'a' && string[item] <= 'z') {
ret += levels[level][string[item] - 'a'];
} else {
ret += string[item];
}
//ret = replace(alphabet[item], levels[level][item]);
}
return ret;
}
return message;
}
|