ТС, дарю:
[src=java]
public final class BypassCrypt
{
private static final char[] CHAR_ARRAY_BYPASS = "bypass".toCharArray();
private static final int LETTER_SMALL_LAST = 'z';
private static final int LETTER_SMALL_FIRST = 'a';
private static final int LETTER_BIG_LAST = 'Z';
private static final int LETTER_BIG_FIRST = 'A';
private static final int NUMBER_LAST = '9';
private static final int NUMBER_FIRST = '0';
private static final int[] DEFAULT_EXCHANGE;
static
{
DEFAULT_EXCHANGE = new int[LETTER_SMALL_LAST - LETTER_SMALL_FIRST + LETTER_BIG_LAST - LETTER_BIG_FIRST + NUMBER_LAST - NUMBER_FIRST + 3];
int index = DEFAULT_EXCHANGE.length, i;
for (i = LETTER_SMALL_LAST + 1; i-- > LETTER_SMALL_FIRST
{
DEFAULT_EXCHANGE[--index] = i;
}
for (i = LETTER_BIG_LAST + 1; i-- > LETTER_BIG_FIRST
{
DEFAULT_EXCHANGE[--index] = i;
}
for (i = NUMBER_LAST + 1; i-- > NUMBER_FIRST
{
DEFAULT_EXCHANGE[--index] = i;
}
}
private static final char[] getGenExchangeTable()
{
final TIntArrayList useable = new TIntArrayList(DEFAULT_EXCHANGE.length);
useable.add(DEFAULT_EXCHANGE);
final char[] exchangeTable = new char[LETTER_SMALL_LAST - NUMBER_FIRST + 1];
for (int i = exchangeTable.length, j; i-- > 0
{
j = i + NUMBER_FIRST;
if (ArrayUtil.arrayContains(DEFAULT_EXCHANGE, j))
{
exchangeTable[i] = (char) useable.remove(Rnd.get(useable.size()));
}
else
{
exchangeTable[i] = (char) j;
}
}
return exchangeTable;
}
public static final void main(final String[] args)
{
final char[] exchange = getGenExchangeTable();
System.out.println(encrypt("<bypass -b talk_27816339_page 2>", exchange));
}
public static final String encrypt(final String text, final char[] exchange)
{
final char[] toEncrypt = text.toCharArray();
for (int i = 0, j; i < text.length(); i++)
{
if (toEncrypt[i] == '<')
{
for (j = i + 1; j < text.length(); j++)
{
if (toEncrypt[j] == '>')
{
checkBypass(i + 1, j, toEncrypt, exchange);
i = j;
}
}
}
}
return new String(toEncrypt);
}
private static final void checkBypass(int start, int end, final char[] toEncrypt, final char[] exchange)
{
final int len = end - start;
if (len <= CHAR_ARRAY_BYPASS.length)
return;
for (int j = 0; j < len; j++)
{
/* if (toEntrypt)
pos = toEncrypt[i] - NUMBER_FIRST;
if (pos < max && pos >= 0)
toEncrypt[i] = exchange[pos];*/
}
}
@SuppressWarnings("unused")
private static final void encrypt(final int start, final int end, final char[] toEncrypt, final char[] exchange)
{
final int len = end - start;
if (len <= 0)
return;
final int max = exchange.length;
for (int i = end, pos; i-- > start
{
pos = toEncrypt[i] - NUMBER_FIRST;
if (pos < max && pos >= 0)
toEncrypt[i] = exchange[pos];
}
}
public static final String decrypt(final String text)
{
return null;
}
}[/src]
Fortuna - non penis, in manus non recipe.