Java String Encrypt encryptURID(long registrationId)

Here you can find the source of encryptURID(long registrationId)

Description

Method encrypt URID

License

Apache License

Parameter

Parameter Description
registrationId a parameter

Return

encrypted URID

Declaration

public static String encryptURID(long registrationId) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final int M_FACTOR = 3;
    private static final int S_FACTOR = 7;

    /**//from  w  w  w  . j  a va2s  .  c o  m
     * Method encrypt URID
     * @param registrationId
     * @return encrypted URID
     */
    public static String encryptURID(long registrationId) {
        char[] characters = String.valueOf(registrationId).toCharArray();
        StringBuilder encryptedURID = new StringBuilder();

        for (int index = 0; index < characters.length; index++) {
            int code = characters[index];
            char ch = (char) ((code * M_FACTOR) - S_FACTOR);
            encryptedURID.append(Integer.toHexString(ch));

            if ((index + 1) % 4 == 0) {
                encryptedURID.append("-");
            }
        }
        return encryptedURID.toString();
    }
}

Related

  1. encryptPwd(String src)
  2. encryptStrBuff(byte[] resultBytes)
  3. encryptString(final String cadena)
  4. encryptString(String str)
  5. encryptString(String str)
  6. encryptURL(String url)