Skip to content

Instantly share code, notes, and snippets.

@flytzen
Created December 9, 2019 16:28
Show Gist options
  • Save flytzen/a381592b565b163bbd1355fc7e970b42 to your computer and use it in GitHub Desktop.
Save flytzen/a381592b565b163bbd1355fc7e970b42 to your computer and use it in GitHub Desktop.
using System;
namespace MACPlay
{
class Program
{
static void Main(string[] args)
{
int id = 200;
DateTime expiry = DateTime.UtcNow.AddMinutes(15);
var idbytes = BitConverter.GetBytes(id);
var datebytes = BitConverter.GetBytes(expiry.Ticks);
byte[] allstuff = new byte[12];
System.Array.Copy(idbytes, allstuff,4);
System.Array.Copy(datebytes, 0, allstuff, 4, 8);
// protect here!!
//unprotect
var newid = BitConverter.ToInt32(idbytes);
var dateticks = BitConverter.ToInt64(datebytes);
var newexpiry = new DateTime(dateticks, DateTimeKind.Utc);
Console.WriteLine("Hello World!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment