Example #1
0
        /// <summary>
        /// To provide byte padding to create an instance.
        /// Byte padding to provide that kind of 'ANSI X.923', 'ISO 10126', 'PKCS7' is.
        /// </summary>
        /// <param name="paddingType">type The type of padding bytes (ANSI X.923 : ANSIX923, ISO 10126 : ISO10126, PKCS7 : PKCS7)</param>
        /// <returns>Byte padding instance, if that does not support the null of the padding bytes is returned.</returns>
        public static BlockPadding GetInstance(string paddingType) {
            paddingType.ShouldNotBeWhiteSpace("paddingType");

            var isCreate = false;

            if(_instance == null) {
                isCreate = true;
            }
            else if(_instance.PaddingType.Equals(paddingType) == false) {
                isCreate = true;
            }

            if(isCreate) {
                switch(paddingType.ToUpper()) {
                    case ANSIX:
                        _instance = new AnsiX923Padding();
                        break;
                    case ISO:
                    case PKCS7:
                    default:
                        _instance = null;
                        break;
                }
            }
            return _instance;
        }
Example #2
0
        /// <summary>
        /// To provide byte padding to create an instance.
        /// Byte padding to provide that kind of 'ANSI X.923', 'ISO 10126', 'PKCS7' is.
        /// </summary>
        /// <param name="paddingType">type The type of padding bytes (ANSI X.923 : ANSIX923, ISO 10126 : ISO10126, PKCS7 : PKCS7)</param>
        /// <returns>Byte padding instance, if that does not support the null of the padding bytes is returned.</returns>
        public static BlockPadding GetInstance(string paddingType)
        {
            paddingType.ShouldNotBeWhiteSpace("paddingType");

            var isCreate = false;

            if (_instance == null)
            {
                isCreate = true;
            }
            else if (_instance.PaddingType.Equals(paddingType) == false)
            {
                isCreate = true;
            }

            if (isCreate)
            {
                switch (paddingType.ToUpper())
                {
                case ANSIX:
                    _instance = new AnsiX923Padding();
                    break;

                case ISO:
                case PKCS7:
                default:
                    _instance = null;
                    break;
                }
            }
            return(_instance);
        }