Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.util.Base64;
import java.io.UnsupportedEncodingException;

public class Main {

    public static String encryption(String pwd) throws UnsupportedEncodingException {
        byte[] bytes = pwd.getBytes("utf-8");
        for (int i = 0; i < bytes.length; i++) {
            if (i % 2 == 0) {
                bytes[i] += 1;
            } else {
                bytes[i] -= 1;
            }
        }
        return Base64.encodeToString(bytes, Base64.DEFAULT);
    }
}