java加密

    /**
     * Returns a decrypted string that was originally 
     * encrypted using the MetCareTNGEncryptor utility.
     *  
     * @param encrypted string
     * @return decrypted string
     */
    public static String decryptPassword(String input)
    {
        StringBuffer output = new StringBuffer();

        for (int i = 0; i < input.length(); i++)
        {
            char c = input.charAt(i);
            char newChar = encryptChar(c);
            output.append(newChar);
        }
        return output.toString();
    }
 /**
     * Encrypts the character utilizing the ROT13 algorithm. 
     *  
     * @return char
     * @param c java.lang.String
     */
    private static char encryptChar(char c)
    {
        // Disregard all non-alpha chars
        if (c > 'z' || c < 'A')
            return c;

        char a = '\u0000';

        if (c >= 'a' && c <= 'z')
            a = 'a';

        if (c >= 'A' && c <= 'Z')
            a = 'A';

        if (a != '\u0000')
            c = (char) ((((c - a) + 13) % 26) + a);

        return c;
    }

你可能感兴趣的:(java,C++,c,C#)