Java String Encrypt EncryptDecrypt(String value)

Here you can find the source of EncryptDecrypt(String value)

Description

Encrypt Decrypt

License

Open Source License

Declaration

public static String EncryptDecrypt(String value) 

Method Source Code

//package com.java2s;
/**/*from   www.j a  v a  2 s  . c  o m*/
 *  
 * Copyright (c) 2015 Fannie Mae, All rights reserved.
 * This program and the accompany materials are made available under
 * the terms of the Fannie Mae Open Source Licensing Project available 
 * at https://github.com/FannieMaeOpenSource/ezPie/wiki/License
 * 
 * ezPIE? is a registered trademark of Fannie Mae
 * 
 */

public class Main {
    public static String EncryptDecrypt(String value) {
        byte[] aCrypt = { 0x34 };
        byte[] aInput = value.getBytes();
        int iLength = aInput.length;
        byte[] aOutput = new byte[iLength];

        for (int pos = 0; pos < iLength; ++pos) {
            aOutput[pos] = (byte) (aInput[pos] ^ aCrypt[0]);
        }
        return new String(aOutput);
    }

    public static String EncryptDecrypt(String value, String key) {
        byte[] aCrypt = key.getBytes();
        byte[] aInput = value.getBytes();

        int iLength = aInput.length;
        int iKeyLength = aCrypt.length;

        byte[] aOutput = new byte[iLength];

        int ikeypos = 0;
        for (int pos = 0; pos < iLength; ++pos) {
            aOutput[pos] = (byte) (aInput[pos] ^ aCrypt[ikeypos]);
            ikeypos++;
            if (ikeypos >= iKeyLength) {
                ikeypos = 0;
            }
        }
        return new String(aOutput);
    }
}

Related

  1. encrypt0(final byte[] result)
  2. encryptBankCardNo(String cardNo)
  3. encryptBankCardNoLast4Bits(String cardNo)
  4. encryptBytes(final byte[] b, final int i)
  5. encryptChar(String caracter, int variable, int indice)
  6. encryptEmailId(String emailId)
  7. encryptIfNotEncrypted(String s)
  8. encryption(String str, int k)
  9. encryptPlayerChat(byte[] is, int i_25_, int i_26_, int i_27_, byte[] is_28_)