Java Base64 base64CharToValue(byte c)

Here you can find the source of base64CharToValue(byte c)

Description

base Char To Value

License

Apache License

Declaration

public static int base64CharToValue(byte c) 

Method Source Code

//package com.java2s;
/*/*w ww.  j  a  va2s .co  m*/
   Copyright 2007-2013 Hendrik Iben, University Bremen
    
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

public class Main {
    public static int base64CharToValue(byte c) {
        if (c >= 'A' && c <= 'Z') {
            return c - 'A';
        }
        if (c >= 'a' && c <= 'z') {
            return 26 + (c - 'a');
        }
        if (c >= '0' && c <= '9') {
            return 52 + (c - '0');
        }
        if (c == '+')
            return 62;
        if (c == '/')
            return 63;
        if (c == '=')
            return 0;

        return -1;
    }
}

Related

  1. base64(String string)
  2. base64(String value)
  3. base64Append(StringBuilder sb, int digit, boolean haveNonZero)
  4. base64Append(StringBuilder sb, int digit, boolean haveNonZero)
  5. base64Character(int number)
  6. base64enc(byte[] in)
  7. base64Pad(String s)
  8. base64ReadChunk(InputStream in, byte[] chunk)
  9. base64ToBits(char data)