Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/spongycastle/util/encoders/UrlBase64Encoder.java')
-rw-r--r--core/src/main/java/org/spongycastle/util/encoders/UrlBase64Encoder.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/src/main/java/org/spongycastle/util/encoders/UrlBase64Encoder.java b/core/src/main/java/org/spongycastle/util/encoders/UrlBase64Encoder.java
new file mode 100644
index 00000000..dc6f1ed7
--- /dev/null
+++ b/core/src/main/java/org/spongycastle/util/encoders/UrlBase64Encoder.java
@@ -0,0 +1,25 @@
+package org.spongycastle.util.encoders;
+
+/**
+ * Convert binary data to and from UrlBase64 encoding. This is identical to
+ * Base64 encoding, except that the padding character is "." and the other
+ * non-alphanumeric characters are "-" and "_" instead of "+" and "/".
+ * <p>
+ * The purpose of UrlBase64 encoding is to provide a compact encoding of binary
+ * data that is safe for use as an URL parameter. Base64 encoding does not
+ * produce encoded values that are safe for use in URLs, since "/" can be
+ * interpreted as a path delimiter; "+" is the encoded form of a space; and
+ * "=" is used to separate a name from the corresponding value in an URL
+ * parameter.
+ */
+public class UrlBase64Encoder extends Base64Encoder
+{
+ public UrlBase64Encoder()
+ {
+ encodingTable[encodingTable.length - 2] = (byte) '-';
+ encodingTable[encodingTable.length - 1] = (byte) '_';
+ padding = (byte) '.';
+ // we must re-create the decoding table with the new encoded values.
+ initialiseDecodingTable();
+ }
+}