Created
August 9, 2023 07:56
-
-
Save VulBusters/f5a39c2b6809e511737bd5cbdfcaba02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void KeyExchange() | |
{ | |
String publicKeyPem = PlayerPrefs.GetString("clientPublicKey"); | |
if(String.IsNullOrEmpty(publicKeyPem)) | |
{ | |
throw new PlayerPrefsItemNotFoundException("clientPublicKey"); | |
} | |
String EcPublicKeyDerHexStr = EcPemtoDer(publicKeyPem, "public"); | |
String serializedHttpBody = JsonConvert.SerializeObject(EcPublicKeyDerHexStr); | |
var (headers, jsonResponseText) = RequestHandler.Post("xxx.azurewebsites.com/api/KeyExchange"), null, false, serializedHttpBody); | |
KeyExchangeDto kexDto = new KeyExchangeDto(); | |
try | |
{ | |
kexDto = JsonConvert.DeserializeObject<KeyExchangeDto>(jsonResponseText); | |
} | |
catch(JsonSerializationException ex) | |
{ | |
Debug.Log(ex.Message); | |
} | |
// the data that retrieve from the server | |
String keyId = kexDto.KeyId; | |
String salt = kexDto.Salt; | |
String serverPublicKey = kexDto.ServerPublicKey; | |
PlayerPrefs.SetString("keyId", keyId); | |
PlayerPrefs.SetString("salt", salt); | |
PlayerPrefs.SetString("serverPublicKey", serverPublicKey); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment