public static string GetLoginToken(int loginId, DateTime expirationDate, bool oneTimeUse = true) { byte[] expirationBytes = BitConverter.GetBytes(expirationDate.Ticks); byte[] loginIdBytes = BitConverter.GetBytes(loginId); var randomBytes = GetRandomBytes(); byte[] oneTimeUseBytes = BitConverter.GetBytes(oneTimeUse); byte[] allTheBytes = new byte[loginIdBytes.Length + expirationBytes.Length + randomBytes.Length + sizeof(bool)]; Buffer.BlockCopy(loginIdBytes, 0, allTheBytes, 0, loginIdBytes.Length); Buffer.BlockCopy(expirationBytes, 0, allTheBytes, loginIdBytes.Length, expirationBytes.Length); Buffer.BlockCopy(randomBytes, 0, allTheBytes, loginIdBytes.Length + expirationBytes.Length, randomBytes.Length); Buffer.BlockCopy(oneTimeUseBytes, 0, allTheBytes, loginIdBytes.Length + expirationBytes.Length + randomBytes.Length, oneTimeUseBytes.Length); byte[] encryptedBytes = BasicEncryption.EncryptBytesToBytes_Aes(allTheBytes); string encryptedData = BasicEncryption.Base64EncodeUrlSafe(encryptedBytes); return(encryptedData); }