OpenStory.Cryptography.RollingIv.RollingIv C# (CSharp) Method

RollingIv() public method

Initializes a new instance of the RollingIv class.
/// Thrown if or is . /// /// Thrown if does not have exactly 4 elements. ///
public RollingIv ( ICryptoAlgorithm algorithm, byte initialIv, ushort versionMask ) : System
algorithm ICryptoAlgorithm The instance for this session.
initialIv byte The initial IV for this instance.
versionMask ushort The version mask used for header creation.
return System
        public RollingIv(ICryptoAlgorithm algorithm, byte[] initialIv, ushort versionMask)
        {
            Guard.NotNull(() => algorithm, algorithm);
            Guard.NotNull(() => initialIv, initialIv);

            if (initialIv.Length != 4)
            {
                throw new ArgumentException(CommonStrings.IvMustBe4Bytes, "initialIv");
            }

            this.algorithm = algorithm;
            this.iv = initialIv.FastClone();

            // Flip the version mask.
            this.versionMask = (ushort)((versionMask >> 8) | ((versionMask & 0xFF) << 8));
        }