bitcoin-visualizer's Issues
Conversions Class (non-working)
public class conversions {
private static final String B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
private static final String ADDRESS_VERSION = "00";
public static String decodeHex(String input){
String fin = new String("#" + input);
fin = Long.toString(Long.decode(fin));
return fin;
}
public static String encodeHex(String input){
String fin = new String(Long.toHexString(Long.parseLong(input)));
return fin;
}
public static String decodeBase58(String input){
char orig[] = input.toCharArray();
String val = "";
long fin = 0;
String finalStr = "";
for(Integer i = 0; i < input.length(); i++){
Integer cur = (B58.indexOf(orig[i]));
fin = fin * 58;
fin = fin + cur;
}
val = encodeHex(Long.toString(fin));
for(Integer i = 0; (i < input.length()) && (orig[i] == '1'); i++){
finalStr = "00" + val;
}
if (finalStr.length() % 2 != 0) {
finalStr = "0" + finalStr;
}
return (finalStr);
}
public static String encodeBase58(String input){
if(input.length() % 2 != 0){
// Throw exception
}
String orig = input;
Integer val = Integer.parseInt(decodeHex(orig));
String fin = "";
while(val > 0){
Integer div = val / 58;
Integer mod = val % 58;
val = div;
fin = fin + B58.charAt(mod);
}
String temp = new StringBuffer(fin).reverse().toString();
fin = temp;
for(int i = 0; (i < orig.length()) && (orig.substring(i, 2) == "00"); i += 2){
fin = "1" + fin;
}
return fin;
}
public static String hash160ToAddress(String input, String AddressVersion){
String hash160 = new String(ADDRESS_VERSION + input);
String check = new String (Integer.toString(Integer.decode("#" + hash160)));
// Need to run it through a hasher
hash160 = (hash160 + check).toUpperCase();
hash160 = encodeBase58(hash160);
return hash160;
}
public static String addressToHash160(String input){
String val = input;
val = decodeBase58(val);
val = input.substring(2, (input.length() - 10));
return val;
}
public static String hash160(String input){
String fin = input;
// convert to hex
// hash the hex
return fin;
}
public static String remove0x(String input){
String fin = input;
if(fin.substring(0, 2) == "0x" || fin.substring(0, 2) == "0X"){
fin = fin.substring(2, fin.length());
}
return fin;
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.