Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class App implements FyersSocketDelegate {
public static void main(String[] args) {
String clientID = "";
String secretKey = "";
String appHashId = "";
String appHashId = getSHA256Hash(clientID, secretKey);

String redirectURI = "https://trade.fyers.in/api-login/redirect-uri/index.html";
String code = "";
Expand Down Expand Up @@ -458,6 +458,25 @@ public void GetOptionChain(FyersClass fyersClass) {

}

public String getSHA256Hash(String clientId, String secretKey) {
String input = String.format("%s:%s", clientId, secretKey);
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] encodedhash = digest.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : encodedhash) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}

public void WebSocket() {
//Order Socket
List<String> list = new ArrayList<>();
Expand Down Expand Up @@ -572,4 +591,4 @@ public void OnMessage(JSONObject message) {
System.out.println("OnMessage: " + message);
}

}
}