// Path: src/main/java/jstellarapi/keys/StellarBase58.java
// public class StellarBase58 {
//     private static final String ALPHABET = "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz";
//     private static final BigInteger BASE = BigInteger.valueOf(58);
// 
//     public static String encode(byte[] input) {
//         // TODO: This could be a lot more efficient.
//         BigInteger bi = new BigInteger(1, input);
//         StringBuffer s = new StringBuffer();
//         while (bi.compareTo(BASE) >= 0) {
//             BigInteger mod = bi.mod(BASE);
//             s.insert(0, ALPHABET.charAt(mod.intValue()));
//             bi = bi.subtract(mod).divide(BASE);
//         }
//         s.insert(0, ALPHABET.charAt(bi.intValue()));
//         // Convert leading zeros too.
//         for (byte anInput : input) {
//             if (anInput == 0)
//                 s.insert(0, ALPHABET.charAt(0));
//             else
//                 break;
//         }
//         return s.toString();
//     }
// 
//     public static byte[] decode(String input) {
//         byte[] bytes = decodeToBigInteger(input).toByteArray();
//         // We may have got one more byte than we wanted, if the high bit of the next-to-last byte was not zero. This
//         // is because BigIntegers are represented with twos-compliment notation, thus if the high bit of the last
//         // byte happens to be 1 another 8 zero bits will be added to ensure the number parses as positive. Detect
//         // that case here and chop it off.
//         boolean stripSignByte = bytes.length > 1 && bytes[0] == 0 && bytes[1] < 0;
//         // Count the leading zeros, if any.
//         int leadingZeros = 0;
//         for (int i = 0; input.charAt(i) == ALPHABET.charAt(0); i++) {
//             leadingZeros++;
//         }
//         // Now cut/pad correctly. Java 6 has a convenience for this, but Android can't use it.
//         byte[] tmp = new byte[bytes.length - (stripSignByte ? 1 : 0) + leadingZeros];
//         System.arraycopy(bytes, stripSignByte ? 1 : 0, tmp, leadingZeros, tmp.length - leadingZeros);
//         return tmp;
//     }
//     
//     public static BigInteger decodeToBigInteger(String input) {
//         BigInteger bi = BigInteger.valueOf(0);
//         // Work backwards through the string.
//         for (int i = input.length() - 1; i >= 0; i--) {
//             int alphaIndex = ALPHABET.indexOf(input.charAt(i));
//             if (alphaIndex == -1) {
//                 throw new RuntimeException("Illegal character " + input.charAt(i) + " at " + i);
//             }
//             bi = bi.add(BigInteger.valueOf(alphaIndex).multiply(BASE.pow(input.length() - 1 - i)));
//         }
//         return bi;
//     }
// }


import java.io.Serializable;
import java.util.Arrays;
import jstellarapi.keys.StellarBase58;
import org.bouncycastle.crypto.digests.SHA256Digest;
package jstellarapi.core;




public class StellarIdentifier implements Serializable {
	private static final long serialVersionUID = -6009723401818144454L;
	String humanReadableIdentifier;
	byte[] payloadBytes;
	int identifierType;
		
	/**
	 * @param payloadBytes
	 * @param identifierType : See ripple_data/protocol/RippleAddress.h
	 */
	public StellarIdentifier(byte[] payloadBytes, int identifierType){
		this.payloadBytes = payloadBytes;
		this.identifierType = identifierType;
	}
	
	public StellarIdentifier(String stringID) {
		this.humanReadableIdentifier = stringID;
// Path: src/main/java/jstellarapi/keys/StellarBase58.java
// public class StellarBase58 {
//     private static final String ALPHABET = "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz";
//     private static final BigInteger BASE = BigInteger.valueOf(58);
// 
//     public static String encode(byte[] input) {
//         // TODO: This could be a lot more efficient.
//         BigInteger bi = new BigInteger(1, input);
//         StringBuffer s = new StringBuffer();
//         while (bi.compareTo(BASE) >= 0) {
//             BigInteger mod = bi.mod(BASE);
//             s.insert(0, ALPHABET.charAt(mod.intValue()));
//             bi = bi.subtract(mod).divide(BASE);
//         }
//         s.insert(0, ALPHABET.charAt(bi.intValue()));
//         // Convert leading zeros too.
//         for (byte anInput : input) {
//             if (anInput == 0)
//                 s.insert(0, ALPHABET.charAt(0));
//             else
//                 break;
//         }
//         return s.toString();
//     }
// 
//     public static byte[] decode(String input) {
//         byte[] bytes = decodeToBigInteger(input).toByteArray();
//         // We may have got one more byte than we wanted, if the high bit of the next-to-last byte was not zero. This
//         // is because BigIntegers are represented with twos-compliment notation, thus if the high bit of the last
//         // byte happens to be 1 another 8 zero bits will be added to ensure the number parses as positive. Detect
//         // that case here and chop it off.
//         boolean stripSignByte = bytes.length > 1 && bytes[0] == 0 && bytes[1] < 0;
//         // Count the leading zeros, if any.
//         int leadingZeros = 0;
//         for (int i = 0; input.charAt(i) == ALPHABET.charAt(0); i++) {
//             leadingZeros++;
//         }
//         // Now cut/pad correctly. Java 6 has a convenience for this, but Android can't use it.
//         byte[] tmp = new byte[bytes.length - (stripSignByte ? 1 : 0) + leadingZeros];
//         System.arraycopy(bytes, stripSignByte ? 1 : 0, tmp, leadingZeros, tmp.length - leadingZeros);
//         return tmp;
//     }
//     
//     public static BigInteger decodeToBigInteger(String input) {
//         BigInteger bi = BigInteger.valueOf(0);
//         // Work backwards through the string.
//         for (int i = input.length() - 1; i >= 0; i--) {
//             int alphaIndex = ALPHABET.indexOf(input.charAt(i));
//             if (alphaIndex == -1) {
//                 throw new RuntimeException("Illegal character " + input.charAt(i) + " at " + i);
//             }
//             bi = bi.add(BigInteger.valueOf(alphaIndex).multiply(BASE.pow(input.length() - 1 - i)));
//         }
//         return bi;
//     }
// }


// Path: src/main/java/jstellarapi/core/StellarIdentifier.java
import java.io.Serializable;
import java.util.Arrays;
import jstellarapi.keys.StellarBase58;
import org.bouncycastle.crypto.digests.SHA256Digest;

package jstellarapi.core;




public class StellarIdentifier implements Serializable {
	private static final long serialVersionUID = -6009723401818144454L;
	String humanReadableIdentifier;
	byte[] payloadBytes;
	int identifierType;
		
	/**
	 * @param payloadBytes
	 * @param identifierType : See ripple_data/protocol/RippleAddress.h
	 */
	public StellarIdentifier(byte[] payloadBytes, int identifierType){
		this.payloadBytes = payloadBytes;
		this.identifierType = identifierType;
	}
	
	public StellarIdentifier(String stringID) {
		this.humanReadableIdentifier = stringID;
		byte[] stridBytes = StellarBase58.decode(stringID);