This Chat is read-only. Login to resume chatting.
import HDWalletKit
func encodePublicKeyToRaw(publicKey: String) -> String? {
guard let data = Data(base64Encoded: publicKey) else {
return nil
}
let rawPublicKey = data.base58EncodedString()
return rawPublicKey
}
// Example usage
let publicKey = "your_public_key_here"
if let rawPublicKey = encodePublicKeyToRaw(publicKey: publicKey) {
print("Raw Public Key: \(rawPublicKey)")
} else {
print("Failed to encode public key.")
}import org.bitcoinj.core.Base58;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.params.MainNetParams;
import org.bouncycastle.util.encoders.Hex;
public class HDPublicKeyEncoder {
public static String encodePublicKeyToRaw(String publicKey) {
byte[] decodedPublicKey = Hex.decode(publicKey);
String rawPublicKey = Base58.encode(decodedPublicKey);
return rawPublicKey;
}
public static String decodeRawPublicKey(String rawPublicKey) {
byte[] decodedRawPublicKey = Base58.decode(rawPublicKey);
ECKey key = ECKey.fromPublicOnly(decodedRawPublicKey);
return key.getPublicKeyAsHex();
}
public static void main(String[] args) {
String publicKey = "your_public_key_here";
String rawPublicKey = encodePublicKeyToRaw(publicKey);
System.out.println("Raw Public Key: " + rawPublicKey);
String decodedPublicKey = decodeRawPublicKey(rawPublicKey);
System.out.println("Decoded Public Key: " + decodedPublicKey);
}
}