Java String Encrypt encrypt(char ch)

Here you can find the source of encrypt(char ch)

Description

encrypt

License

Open Source License

Declaration

private static char encrypt(char ch) 

Method Source Code

//package com.java2s;
/*/*from   w w  w. ja  v  a 2  s.  c om*/
 * $Id: StringUtilities.java,v 1.6 2004/11/03 17:25:52 edankert Exp $
 *
 * Copyright (C) 2002-2004, Cladonia Ltd. All rights reserved.
 *
 * This software is the proprietary information of Cladonia Ltd.  
 * Use is subject to license terms.
 */

public class Main {
    private static final char[][] table = { { 'a', '3' }, { 'b', 'x' }, { 'c', '0' }, { 'd', 'G' }, { 'e', '4' },
            { 'f', 'D' }, { 'g', '8' }, { 'h', 'w' }, { 'i', 'y' }, { 'j', '2' }, { 'k', 'C' }, { 'l', 'f' },
            { 'm', 'F' }, { 'n', 'j' }, { 'o', 'z' }, { 'p', 'H' }, { 'q', 'b' }, { 'r', 'n' }, { 's', 'M' },
            { 't', 'v' }, { 'u', 'T' }, { 'v', 'B' }, { 'w', 'k' }, { 'x', 'e' }, { 'y', 'U' }, { 'z', '1' },

            { '0', 'O' }, { '1', 'p' }, { '2', 'I' }, { '3', 'r' }, { '4', 'K' }, { '5', 't' }, { '6', 'i' },
            { '7', 'q' }, { '8', 'N' }, { '9', 'P' },

            { 'A', 'V' }, { 'B', '6' }, { 'C', 'Z' }, { 'D', 'c' }, { 'E', 'd' }, { 'F', 'h' }, { 'G', 'E' },
            { 'H', 'o' }, { 'I', 'g' }, { 'J', 'l' }, { 'K', '5' }, { 'L', 'a' }, { 'M', 'm' }, { 'N', 'W' },
            { 'O', 'J' }, { 'P', 'Y' }, { 'Q', 'X' }, { 'R', 'R' }, { 'S', 'L' }, { 'T', 'u' }, { 'U', '9' },
            { 'V', 's' }, { 'W', 'A' }, { 'X', '7' }, { 'Y', 'Q' }, { 'Z', 'S' } };

    private static char encrypt(char ch) {
        for (int i = 0; i < table.length; i++) {
            if (table[i][0] == ch) {
                return table[i][1];
            }
        }

        return ch;
    }

    public static String encrypt(String string) {
        if (string != null) {
            return encrypt(string.toCharArray());
        }

        return null;
    }

    public static String encrypt(char[] chars) {
        for (int i = 0; i < chars.length; i++) {
            chars[i] = encrypt(chars[i]);
        }

        String result = new String(chars);
        //      System.out.println( "StringUtilities.encrypt( "+new String( chars)+") ["+result+"]");
        return result;
    }
}

Related

  1. encrypt(byte[] data)
  2. encrypt(byte[] plaintextBytes, int r, int n)
  3. encrypt(byte[] serialize)
  4. encrypt(int original, int salt)
  5. encrypt(String data, String key)
  6. encrypt(String inStr)
  7. encrypt(String s)