Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Apache Commons Codec Source Code
Apache Commons Codec library
provides implementations of common encoders and decoders such as Base64, Hex,
Phonetic and URLs.
Apache Commons Codec Source Code files are provided in both binary packge (commons-codec-3.15-bin.zip) and source package (commons-codec-3.15-src.zip). You can download them at Apache Commons Codec Website.
Apache Commons Codec Source Code has no dependencies. You can compile it to generate your own version of Apache Commons Codec JAR file.
The source code of Apache Commons Codec 1.15 is provided below:
✍: FYIcenter
⏎ org/apache/commons/codec/digest/B64.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.commons.codec.digest; import java.security.SecureRandom; import java.util.Random; /** * Base64-like method to convert binary bytes into ASCII chars. * <p> * TODO: Can Base64 be reused? * </p> * <p> * This class is immutable and thread-safe. * </p> * * @since 1.7 */ class B64 { /** * Table with characters for Base64 transformation. */ static final String B64T_STRING = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; /** * Table with characters for Base64 transformation. */ static final char[] B64T_ARRAY = B64T_STRING.toCharArray(); /** * Base64 like conversion of bytes to ASCII chars. * * @param b2 * A byte from the result. * @param b1 * A byte from the result. * @param b0 * A byte from the result. * @param outLen * The number of expected output chars. * @param buffer * Where the output chars is appended to. */ static void b64from24bit(final byte b2, final byte b1, final byte b0, final int outLen, final StringBuilder buffer) { // The bit masking is necessary because the JVM byte type is signed! int w = ((b2 << 16) & 0x00ffffff) | ((b1 << 8) & 0x00ffff) | (b0 & 0xff); // It's effectively a "for" loop but kept to resemble the original C code. int n = outLen; while (n-- > 0) { buffer.append(B64T_ARRAY[w & 0x3f]); w >>= 6; } } /** * Generates a string of random chars from the B64T set. * <p> * The salt is generated with {@link SecureRandom}. * </p> * * @param num Number of chars to generate. * @return a random salt {@link String}. */ static String getRandomSalt(final int num) { return getRandomSalt(num, new SecureRandom()); } /** * Generates a string of random chars from the B64T set. * <p> * The salt is generated with the {@link Random} provided. * </p> * * @param num Number of chars to generate. * @param random an instance of {@link Random}. * @return a random salt {@link String}. */ static String getRandomSalt(final int num, final Random random) { final StringBuilder saltString = new StringBuilder(num); for (int i = 1; i <= num; i++) { saltString.append(B64T_STRING.charAt(random.nextInt(B64T_STRING.length()))); } return saltString.toString(); } }
⏎ org/apache/commons/codec/digest/B64.java
Or download all of them as a single archive file:
File name: commons-codec-1.15-sources.jar File size: 364441 bytes Release date: 2020-09-01 Download
⇒ Download and Install commons-codec-1.15-bin.zip
2020-06-28, 100407👍, 1💬
Popular Posts:
What Is HttpComponents commons-httpclient-3.1.j ar?HttpComponents commons-httpclient-3.1.j aris the ...
Apache BCEL Source Code Files are inside the Apache BCEL source package file like bcel-6.6.1-src.zip...
How to run "jar" command from JDK tools.jar file? "jar" is the JAR (Java Archive) file management co...
The JDT project provides the tool plug-ins that implement a Java IDE supporting the development of a...
Oracle Business Intelligence (BI) Beans enables developers to productively build business intelligen...