Created
October 6, 2016 08:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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