Skip to content

Instantly share code, notes, and snippets.

@suchithm
suchithm / PlatformServices.cs
Last active March 20, 2023 12:35
RazorPay Android checkout
using Com.Razorpay;
using System.Net.Http;
using Newtonsoft.Json
using Xamarin.Forms;
[assembly: Dependency(typeof(PaymentInterface))]
namespace PlatformServices
{
public class PaymentInterface :IPaymentInterface
{
@suchithm
suchithm / CustomWebViewRenderer.cs
Last active March 20, 2023 12:27
Custom WebView Renderer
using System;
using Diet.iOS.CustomRenderer;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using WebKit;
using Foundation;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
CustomWebView.cs:
using System;
using Xamarin.Forms;
namespace CustomControls
{
public class CustomWebView : WebView
{
}
@suchithm
suchithm / MyActivity.cs
Created February 22, 2022 12:37
Handling StartActivityForResult | OnActivityResult Deprecated in Xamarin Android
using AndroidX.Activity.Result;
using AndroidX.Activity.Result.Contract;
[Activity(Label = "EditImageActivity", MainLauncher = false)]
public class MyActivity : Activity
{
private ActivityResultCallback _activityResultCallback;
private ActivityResultLauncher _activityResultLauncher;
public static int _requestCode;
@suchithm
suchithm / EncryptDecrypt.cs
Created February 4, 2022 13:25
Encrypt decrypt string
public static byte[] iv;
public byte[] DoEncryptionString(string strText)
{
var secretKey = GetKeyFromKeyStore();
Cipher cipher = Cipher.GetInstance("AES/GCM/NoPadding");
cipher.Init(Javax.Crypto.CipherMode.EncryptMode, secretKey);
iv = cipher.GetIV();
var encryption = cipher.DoFinal(System.Text.Encoding.UTF8.GetBytes(strText));
return encryption;
@suchithm
suchithm / DoDecryption.cs
Created February 4, 2022 13:18
DoDecryption
private void DoDecryption(string src, string dest)
{
//iv = Base64.Decode(ivString , Base64Flags.NoWrap);
if (iv != null && iv.Length > 0)
{
var secretKey = GetKeyFromKeyStore();
Cipher cipher = Cipher.GetInstance("AES/GCM/NoPadding");
Javax.Crypto.Spec.GCMParameterSpec spec = new Javax.Crypto.Spec.GCMParameterSpec(128, iv);
cipher.Init(Javax.Crypto.CipherMode.DecryptMode, secretKey, spec);
@suchithm
suchithm / DoEncryption.cs
Created February 4, 2022 12:48
DoEncryption
public static byte[] iv;
private void DoEncryption(string src, string dest)
{
IKey secretKey = GetKeyFromKeyStore();
Cipher cipher = Cipher.GetInstance("AES/GCM/NoPadding");
cipher.Init(Javax.Crypto.CipherMode.EncryptMode, secretKey);
iv = cipher.GetIV();
//var ivString = Base64.EncodeToString(iv, Base64Flags.NoWrap); //converted iv byte to string
var bytes = System.IO.File.ReadAllBytes(src);
@suchithm
suchithm / IEmployeeService.cs
Last active October 16, 2020 04:54
IEmployeeService
using System.Collections.Generic;
namespace ServiceManager
{
public interface IEmployeeService
{
List<string> GetEmployeeNameList();
}
}
@suchithm
suchithm / EmployeeService.cs
Last active October 15, 2020 13:35
EmployeeService class
using System;
using System.Collections.Generic;
namespace ServiceManager
{
public class EmployeeService : IEmployeeService
{
public EmployeeService()
{
}
@suchithm
suchithm / ViewModelLocator.cs
Last active October 15, 2020 13:46
ViewModelLocator
using CommonServiceLocator;
namespace SampleAutoFacDI.ViewModels
{
public class ViewModelLocator
{
static ViewModelLocator()
{
AutoFacContainer.Initialize();
}