liuhongbo

Untitled

Jul 9th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. var username = "{your username}";
  2. var password = "{your password}";
  3.  
  4. username = "bo@demo";
  5. password = "123";
  6. var ticketHeader = api.GetPublicKey("Test", "F52D2965BF8318F", out string publicKey);
  7. if (publicKey == null)
  8. {
  9.     throw new Exception("Can not get public key.");
  10. }          
  11.  
  12. RSACryptoServiceProvider key = new RSACryptoServiceProvider();
  13. key.FromXmlString(publicKey);
  14. UnicodeEncoding enc = new UnicodeEncoding();
  15.  
  16. byte[] encryptedPassword;
  17.  
  18. encryptedPassword = key.Encrypt(enc.GetBytes(password), false);
  19.  
  20. if (api.Login(ticketHeader, username, encryptedPassword) == false)
  21. {
  22.     throw new Exception("Login failed.");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment