Mega Code Archive
An implementation of the ROT-13 algorithm
/*
* Copyright WizTools.org
* Licensed under the Apache License, Version 2.0:
* http://www.apache.org/licenses/LICENSE-2.0
*/
//package org.wiztools.commons;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* An implementation of the ROT-13 algorithm. The lookup table is defined as a
* constant in the code: making this implementation pretty fast.
* @author subhash
*/
public final class Rot13 {
private static final Map map;
static {
final char[] lookup1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
final char[] lookup2 = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm".toCharArray();
Map m = new HashMap();
for(int i=0; i