@anonymous/

AdorableSlushyIrc

C#

No description

fork
loading
Files
  • main.cs
  • main.exe

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5779129079602472","path":"main.cs","file":{"path":"main.cs","content":{"asEncoding":{"base64":"dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uU2VjdXJpdHkuQ3J5cHRvZ3JhcGh5Owp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLklPOwoKY2xhc3MgTWFpbkNsYXNzIHsKICAKICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbiAoc3RyaW5nW10gYXJncykgewogICAgLy8gR3JhZGVzIEpvdW5yZXkgQXV0aG9yaXphdGlvbgogICAgLy8gRXhhbXBsZSBvZiBnZW5lcmF0aW5nIGEgTUFDIGtleSBmb3IgICAgIAogICAgLy8gQVBJIGtleSBhbmQgc2VjcmV0IGFyZSBzZXQgd2l0aGluIHRoZSBCdWlsZGluZyBCbG9jayBzZXR0aW5ncwogICAgc3RyaW5nIEFQSUtleSA9ICJ0aGlzX2lzX3lvdXJfYXBpX2tleSI7CiAgICBzdHJpbmcgc2VjcmV0ID0gIm5vX29uZV9rbm93c190aGlzIjsKICAgIGludCB2YWxpZFRpbWVNUyA9IDEwMDAwOyAKCiAgICAvLyBDdXJyZW50IHRpbWVzdGFtcCBpbiBNaWxsaXNlY29uZHMKICAgIHN0cmluZyBjdXJyZW50VGltZXN0YW1wID0gRGF0ZVRpbWVPZmZzZXQuTm93LlRvVW5peFRpbWVNaWxsaXNlY29uZHMoKS5Ub1N0cmluZygpOwogICAgc3RyaW5nIHRpbWVzdGFtcEV4cGlyeSA9IChEYXRlVGltZS5Ob3cpLkFkZE1pbGxpc2Vjb25kcyh2YWxpZFRpbWVNUykuVG9TdHJpbmcoKTsKICAgIHN0cmluZyBjb25jYWN0U3RyaW5nID0gc3RyaW5nLkNvbmNhdChBUElLZXksIGN1cnJlbnRUaW1lc3RhbXAsIHNlY3JldCk7CgogICAgLy8gRW5jcnlwdAogICAgTUQ1IG1kNSA9IG5ldyBNRDVDcnlwdG9TZXJ2aWNlUHJvdmlkZXIoKTsKICAgIFVURjhFbmNvZGluZyBlbmNvZGVyID0gbmV3IFVURjhFbmNvZGluZygpOwogICAgQnl0ZVtdIGVuY29kZWRCeXRlcyA9IG1kNS5Db21wdXRlSGFzaChlbmNvZGVyLkdldEJ5dGVzKGNvbmNhY3RTdHJpbmcpKTsKICAgIHN0cmluZyBNQUMgPSBCaXRDb252ZXJ0ZXIuVG9TdHJpbmcoZW5jb2RlZEJ5dGVzKS5SZXBsYWNlKCItIiwgIiIpLlRvTG93ZXIoKTsKICAgICAgICAgIAogICAgQ29uc29sZS5Xcml0ZUxpbmUoIioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiIpOwogICAgQ29uc29sZS5Xcml0ZUxpbmUoIk1BQzogIiArIE1BQyk7CiAgICBDb25zb2xlLldyaXRlTGluZSAoIlZhbGlkIHVudGlsOiAiICsgdGltZXN0YW1wRXhwaXJ5KTsKICAgIENvbnNvbGUuV3JpdGVMaW5lKCIqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioiKTsKICB9Cgp9"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;

class MainClass {
  
  public static void Main (string[] args) {
    // Grades Jounrey Authorization
    // Example of generating a MAC key for     
    // API key and secret are set within the Building Block settings
    string APIKey = "this_is_your_api_key";
    string secret = "no_one_knows_this";
    int validTimeMS = 10000; 

    // Current timestamp in Milliseconds
    string currentTimestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString();
    string timestampExpiry = (DateTime.Now).AddMilliseconds(validTimeMS).ToString();
    string concactString = string.Concat(APIKey, currentTimestamp, secret);

    // Encrypt
    MD5 md5 = new MD5CryptoServiceProvider();
    UTF8Encoding encoder = new UTF8Encoding();
    Byte[] encodedBytes = md5.ComputeHash(encoder.GetBytes(concactString));
    string MAC = BitConverter.ToString(encodedBytes).Replace("-", "").ToLower();
          
    Console.WriteLine("******************************");
    Console.WriteLine("MAC: " + MAC);
    Console.WriteLine ("Valid until: " + timestampExpiry);
    Console.WriteLine("******************************");
  }

}