GenTwo
GenTwo
CC#
Created by GenTwo on 2/26/2023 in #help
❔ X509Certificate Help
7 replies
CC#
Created by GenTwo on 2/23/2023 in #help
❔ Java => C#
Hi all, Would anyone know enough Java to convert this codeblock from Java to C#? ChatGPT failed on this convert lol
package <route>;

import lombok.Getter;
import org.json.JSONObject;
import okhttp3.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

@Getter
public class License {

private final String licenseKey;
private final String product;
private final String version;

private int statusCode;
private String discordName;
private String discordID;
private String statusMsg;
private boolean valid;

public License(String licenseKey, String product, String version) {
this.licenseKey = licenseKey;
this.product = product;
this.version = version;

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"license\": \""+ licenseKey +"\",\n \"product\": \""+ product +"\",\n \"version\": \""+ version +"\"\n}");
Request request = new Request.Builder()
.url("http://<ip>:<port>/api/client")
.method("POST", body)
.addHeader("Authorization", "<api-key>")
.build();
Response response = client.newCall(request).execute();

String data = response.body().string();
JSONObject obj = new JSONObject(data);

if (!obj.has("status_msg") || !obj.has("status_id")) return;

statusCode = obj.getInt("status_code");
statusMsg = obj.getString("status_msg");

if (!obj.has("status_overview")) return;

discordName = obj.getString("discord_tag");
discordID = obj.getString("discord_id");

valid = true;
}
}
package <route>;

import lombok.Getter;
import org.json.JSONObject;
import okhttp3.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

@Getter
public class License {

private final String licenseKey;
private final String product;
private final String version;

private int statusCode;
private String discordName;
private String discordID;
private String statusMsg;
private boolean valid;

public License(String licenseKey, String product, String version) {
this.licenseKey = licenseKey;
this.product = product;
this.version = version;

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"license\": \""+ licenseKey +"\",\n \"product\": \""+ product +"\",\n \"version\": \""+ version +"\"\n}");
Request request = new Request.Builder()
.url("http://<ip>:<port>/api/client")
.method("POST", body)
.addHeader("Authorization", "<api-key>")
.build();
Response response = client.newCall(request).execute();

String data = response.body().string();
JSONObject obj = new JSONObject(data);

if (!obj.has("status_msg") || !obj.has("status_id")) return;

statusCode = obj.getInt("status_code");
statusMsg = obj.getString("status_msg");

if (!obj.has("status_overview")) return;

discordName = obj.getString("discord_tag");
discordID = obj.getString("discord_id");

valid = true;
}
}
11 replies
CC#
Created by GenTwo on 2/21/2023 in #help
❔ Windows Form help
25 replies
CC#
Created by GenTwo on 1/11/2023 in #help
❔ Console Application Authentication help
Hello developers, I am planning to sell a console application and I am in search of a public service that can generate license keys, register users with username, password, and key, and automatically log them in if the hardware ID matches. Can anyone recommend any suitable APIs for this purpose? I'm no c# genius so an intermediate friendly solution would be ideal. Thank you!
29 replies