fork(1) download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Security.Cryptography;
  6.  
  7. public class Programa
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var methodName = "Tools/SubscriberCampaignActivation".ToLower();
  12. var stringToHash = "5aafc741ff855d9e" + methodName;
  13. string methodHash = "";
  14. using (MD5 md5Hash = MD5.Create())
  15. {
  16. byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(stringToHash));
  17. StringBuilder sBuilder = new StringBuilder();
  18. for (int i = 0; i < data.Length; i++)
  19. {sBuilder.Append(data[i].ToString("x2"));}
  20. methodHash = sBuilder.ToString();
  21. Console.WriteLine("The MD5 hash of " + stringToHash + " is: " + methodHash + ".");
  22.  
  23. }
  24.  
  25.  
  26. string publicKey = "<RSAKeyValue><Modulus>wEyodsTjUtDbb8A652Dh/ZPwLoZKAA9N20T5hiUNtGFxnSRWh9xB1WIAwtnz9FDLsT73PiiPyiBLhmI511cyAC+upKqKCtk7OR0fHzlRaH/h7H71X4PAxxes0xYLuEaPwNcanLSB1Tb5e84/JqrZhSqkIxaV5CgNVlRwiU7V5WM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
  27. Encryptor encryptor = new Encryptor();
  28. string token = encryptor.EncryptRSA(methodHash, publicKey);
  29. Console.WriteLine("RSA is: " + token);
  30. }
  31. }
  32.  
  33.  
  34. class Encryptor
  35. {
  36. private static UnicodeEncoding _encoder = new UnicodeEncoding();
  37. public string EncryptRSA(string data, string publicKey)
  38. {
  39. try{
  40. var rsa = new RSACryptoServiceProvider();
  41. rsa.FromXmlString(publicKey);
  42. var dataToEncrypt = _encoder.GetBytes(data);
  43. byte[] encryptedByteArray = rsa.Encrypt(dataToEncrypt, false);//.ToArray();
  44. var length = encryptedByteArray.Length;//Count
  45. var item = 0;
  46. var sb = new StringBuilder();
  47.  
  48. Console.WriteLine("RSA ECncrypt is: " + encryptedByteArray.Length);
  49. Console.WriteLine("RSA ECncrypt is: " + data);
  50. for(var i = 0; i < data.Length;++i){
  51. Console.WriteLine(data[i]);
  52. }
  53. foreach (var x in encryptedByteArray){
  54. item++;
  55. sb.Append(x);
  56. if (item < length)
  57. sb.Append(",");}
  58.  
  59. return sb.ToString();
  60. }catch
  61. (Exception ex)
  62. {
  63. throw new RSAException();
  64. }
  65. }
  66. class RSAException : Exception
  67. {
  68. public
  69. RSAException() : base("RSA Encryption Error"){}
  70. }
  71. }
Success #stdin #stdout 0.04s 18944KB
stdin
Standard input is empty
stdout
The MD5 hash of 5aafc741ff855d9etools/subscribercampaignactivation is: b1b33f289f2fe34e40347341311f1819.
RSA ECncrypt is: 128
RSA ECncrypt is: b1b33f289f2fe34e40347341311f1819
b
1
b
3
3
f
2
8
9
f
2
f
e
3
4
e
4
0
3
4
7
3
4
1
3
1
1
f
1
8
1
9
RSA is: 2,62,167,60,41,182,30,249,95,177,246,81,172,209,240,248,58,236,217,248,16,48,48,207,118,223,27,155,71,143,151,134,224,165,129,139,233,27,217,81,211,219,124,172,253,238,214,206,50,22,44,13,242,207,23,207,36,121,10,238,34,199,213,80,62,215,33,4,95,240,151,134,205,253,180,142,43,85,245,79,135,109,207,212,42,225,29,20,104,181,51,82,52,231,78,73,67,66,69,140,225,235,144,123,41,13,134,227,189,126,192,252,222,245,135,72,93,239,167,54,218,191,12,118,204,193,5,143