File tree Expand file tree Collapse file tree
src/main/java/io/ipfs/multibase Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99public class Multibase {
1010
1111 public enum Base {
12- Base1 ('1' ),
13- Base2 ('0' ),
14- Base8 ('7' ),
15- Base10 ('9' ),
16- Base16 ('f' ),
17- Base16Upper ('F' ),
18- Base32 ('b' ),
19- Base32Upper ('B' ),
20- Base32Pad ('c' ),
21- Base32PadUpper ('C' ),
22- Base32Hex ('v' ),
23- Base32HexUpper ('V' ),
24- Base32HexPad ('t' ),
25- Base32HexPadUpper ('T' ),
26- Base36 ('k' ),
27- Base36Upper ('K' ),
28- Base58BTC ('z' ),
29- Base58Flickr ('Z' ),
30- Base64 ('m' ),
31- Base64Url ('u' ),
32- Base64Pad ('M' ),
33- Base64UrlPad ('U' );
12+ Base1 ("1" ),
13+ Base2 ("0" ),
14+ Base8 ("7" ),
15+ Base10 ("9" ),
16+ Base16 ("f" ),
17+ Base16Upper ("F" ),
18+ Base32 ("b" ),
19+ Base32Upper ("B" ),
20+ Base32Pad ("c" ),
21+ Base32PadUpper ("C" ),
22+ Base32Hex ("v" ),
23+ Base32HexUpper ("V" ),
24+ Base32HexPad ("t" ),
25+ Base32HexPadUpper ("T" ),
26+ Base36 ("k" ),
27+ Base36Upper ("K" ),
28+ Base58BTC ("z" ),
29+ Base58Flickr ("Z" ),
30+ Base64 ("m" ),
31+ Base64Url ("u" ),
32+ Base64Pad ("M" ),
33+ Base64UrlPad ("U" );
3434
35- public char prefix ;
35+ public String prefix ;
3636
37- Base (char prefix ) {
37+ Base (String prefix ) {
3838 this .prefix = prefix ;
3939 }
4040
41- private static Map <Character , Base > lookup = new TreeMap <>();
41+ private static Map <String , Base > lookup = new TreeMap <>();
4242 static {
4343 for (Base b : Base .values ())
4444 lookup .put (b .prefix , b );
4545 }
4646
47- public static Base lookup (char p ) {
47+ public static Base lookup (String p ) {
4848 if (!lookup .containsKey (p ))
4949 throw new IllegalArgumentException ("Unknown Multibase type: " + p );
5050 return lookup .get (p );
@@ -53,7 +53,6 @@ public static Base lookup(char p) {
5353
5454 public static String encode (Base b , byte [] data ) {
5555 switch (b ) {
56- case
5756 case Base58BTC :
5857 return b .prefix + Base58 .encode (data );
5958 case Base16 :
@@ -94,7 +93,7 @@ public static String encode(Base b, byte[] data) {
9493 }
9594
9695 public static Base encoding (String data ) {
97- return Base .lookup (data .charAt ( 0 ));
96+ return Base .lookup (data .substring ( 0 , 1 ));
9897 }
9998
10099 public static byte [] decode (String data ) {
You can’t perform that action at this time.
0 commit comments