本文整理汇总了Java中com.google.bitcoin.core.Base58.encode方法的典型用法代码示例。如果您正苦于以下问题:Java Base58.encode方法的具体用法?Java Base58.encode怎么用?Java Base58.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.bitcoin.core.Base58
的用法示例。
在下文中一共展示了Base58.encode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import com.google.bitcoin.core.Base58; //导入方法依赖的package包/类
@Override
public String toString() {
if (_toStringCache == null) {
int length = hash160.getBytes().length;
byte[] addressBytes = new byte[1 + length + 4];
addressBytes[0] = (byte) version;
System.arraycopy(hash160.getBytes(), 0, addressBytes, 1, length);
byte[] check = Utils.doubleDigest(addressBytes, 0, length + 1);
System.arraycopy(check, 0, addressBytes, length + 1, 4);
_toStringCache = Base58.encode(addressBytes);
}
return _toStringCache;
}
示例2: addKey
import com.google.bitcoin.core.Base58; //导入方法依赖的package包/类
protected boolean addKey(ECKey key, String address, String label, String device_name, String device_version) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String base58Priv = new String(Base58.encode(key.getPrivKeyBytes()));
map.put("addr", address);
if (label != null) {
if (label.length() == 0 || label.length() > 255)
throw new Exception("Label must be between 0 & 255 characters");
map.put("label", label);
}
if (this.isDoubleEncrypted()) {
if (temporySecondPassword == null)
throw new Exception("You must provide a second password");
map.put("priv", encryptPK(base58Priv, getSharedKey(), temporySecondPassword, this.getDoubleEncryptionPbkdf2Iterations()));
} else {
map.put("priv", base58Priv);
}
map.put("created_time", System.currentTimeMillis());
if (device_name != null)
map.put("created_device_name", device_name);
if (device_version != null)
map.put("created_device_version", device_version);
if (getKeysMap().add(map)) {
return true;
} else {
throw new Exception("Error inserting address into keymap");
}
}
示例3: toBase58
import com.google.bitcoin.core.Base58; //导入方法依赖的package包/类
static String toBase58(byte[] ser) {
return Base58.encode(addChecksum(ser));
}