Skip to content

Instantly share code, notes, and snippets.

View lkdocs's full-sized avatar

LaunchKey Documentation Examples lkdocs

View GitHub Profile
def decrypt_RSA(private_key_loc, package):
'''
param: public_key_loc Path to your private key
param: package String to be decrypted
return decrypted string
'''
from base64 import b64decode
from M2Crypto import BIO, RSA
key = open(private_key_loc, "r").read()
priv_key = BIO.MemoryBuffer(key.encode('utf8'))
def encrypt_RSA(public_key_loc, message):
'''
param: public_key_loc Path to public key
param: message String to be encrypted
return base64 encoded encrypted string
'''
from M2Crypto import RSA, BIO
key = open(public_key_loc, "r").read()
pubkey = str(key).encode('utf8')
bio = BIO.MemoryBuffer(pubkey)
<?
public function rsa_decrypt($key, $package) {
$rsa = new Crypt_RSA();
$rsa->setHash("sha256");
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
$rsa->loadKey($key);
$signature = base64_encode($rsa->sign(base64_decode($package)));
return $signature;
}
?>
var logoutResult = await LKOAuthManager.Instance.logout(accessToken) as LaunchKeyLogoutResponse;
public class LaunchKeyLogoutResponse
{
public bool Successful { get; set; }
public bool LoggedOut { get; set; }
public string ErrorMessage { get; set; }
public string ErrorCode { get; set; }
}
var authorizationResult = await LKOAuthManager.Instance.isAuthorized(accessToken) as LaunchKeyIsAuthorizedResponse;
public class LaunchKeyIsAuthorizedResponse
{
public bool Successful { get; set; }
public bool Authorized { get; set; }
public string ErrorMessage { get; set; }
public string ErrorCode { get; set; }
}
public void loginSuccessCallback(string userId, string accessToken)
{
// success
}
public void loginFailureCallback(string errorMessage, string errorCode)
{
// failure
}
LKOAuthManager.Instance.promptForLaunchKeyLogin(loginSuccessCallback, loginFailureCallback);
using LaunchKeyManager;
LKOAuthManager.Instance.init(appKey, redirectUri);
IsLoggedOutResponse response = await LKAuthenticationManager.Instance.logout(_authRequest) as IsLoggedOutResponse;
if (response.LoggedOut)
{
//logged out
}
public class LaunchKeyResponse
{
public bool Successful { get; set; }
public int StatusCode { get; set; }
public string Message { get; set; }
public string MessageCode { get; set; }
}