Skip to content

Instantly share code, notes, and snippets.

@mirsaeedi
Created October 6, 2016 08:07
Show Gist options
  • Save mirsaeedi/e714e85764a4b20950efdbafc763b6c2 to your computer and use it in GitHub Desktop.
Save mirsaeedi/e714e85764a4b20950efdbafc763b6c2 to your computer and use it in GitHub Desktop.
IRShabaCodeAnalyzer helps you to validate Iranian inter bank identification code which name is Shaba Code
public static bool IsValid(string shabaCode)
{
if (string.IsNullOrWhiteSpace(shabaCode))
return false;
shabaCode = shabaCode.Trim();
if (!shabaCode.ToLower().StartsWith("ir"))
return false;
if (shabaCode.Trim().Length != 26)
return false;
var firstPart = "1827" + shabaCode.Substring(2, 2);
var secondPart = shabaCode.Substring(4);
var convertedValue = secondPart + firstPart;
try
{
BigInteger value = BigInteger.Parse(convertedValue);
return value % 97 == 1;
}
catch (Exception)
{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment