コード例 #1
0
        internal Checksum()
        {
            adler32ctx   = new Adler32Context();
            crc16ctx     = new Crc16Context();
            crc32ctx     = new Crc32Context();
            crc64ctx     = new Crc64Context();
            md5ctx       = new Md5Context();
            ripemd160ctx = new Ripemd160Context();
            sha1ctx      = new Sha1Context();
            sha256ctx    = new Sha256Context();
            sha384ctx    = new Sha384Context();
            sha512ctx    = new Sha512Context();
            ssctx        = new SpamSumContext();

            adlerThread     = new Thread(updateAdler);
            crc16Thread     = new Thread(updateCRC16);
            crc32Thread     = new Thread(updateCRC32);
            crc64Thread     = new Thread(updateCRC64);
            md5Thread       = new Thread(updateMD5);
            ripemd160Thread = new Thread(updateRIPEMD160);
            sha1Thread      = new Thread(updateSHA1);
            sha256Thread    = new Thread(updateSHA256);
            sha384Thread    = new Thread(updateSHA384);
            sha512Thread    = new Thread(updateSHA512);
            spamsumThread   = new Thread(updateSpamSum);

            adlerPkt     = new adlerPacket();
            crc16Pkt     = new crc16Packet();
            crc32Pkt     = new crc32Packet();
            crc64Pkt     = new crc64Packet();
            md5Pkt       = new md5Packet();
            ripemd160Pkt = new ripemd160Packet();
            sha1Pkt      = new sha1Packet();
            sha256Pkt    = new sha256Packet();
            sha384Pkt    = new sha384Packet();
            sha512Pkt    = new sha512Packet();
            spamsumPkt   = new spamsumPacket();

            adler32ctx.Init();
            adlerPkt.context = adler32ctx;
            crc16ctx.Init();
            crc16Pkt.context = crc16ctx;
            crc32ctx.Init();
            crc32Pkt.context = crc32ctx;
            crc64ctx.Init();
            crc64Pkt.context = crc64ctx;
            md5ctx.Init();
            md5Pkt.context = md5ctx;
            ripemd160ctx.Init();
            ripemd160Pkt.context = ripemd160ctx;
            sha1ctx.Init();
            sha1Pkt.context = sha1ctx;
            sha256ctx.Init();
            sha256Pkt.context = sha256ctx;
            sha384ctx.Init();
            sha384Pkt.context = sha384ctx;
            sha512ctx.Init();
            sha512Pkt.context = sha512ctx;
            ssctx.Init();
            spamsumPkt.context = ssctx;
        }
コード例 #2
0
        internal static List <ChecksumType> GetChecksums(byte[] data)
        {
            Adler32Context   adler32ctxData   = new Adler32Context();
            Crc16Context     crc16ctxData     = new Crc16Context();
            Crc32Context     crc32ctxData     = new Crc32Context();
            Crc64Context     crc64ctxData     = new Crc64Context();
            Md5Context       md5ctxData       = new Md5Context();
            Ripemd160Context ripemd160ctxData = new Ripemd160Context();
            Sha1Context      sha1ctxData      = new Sha1Context();
            Sha256Context    sha256ctxData    = new Sha256Context();
            Sha384Context    sha384ctxData    = new Sha384Context();
            Sha512Context    sha512ctxData    = new Sha512Context();
            SpamSumContext   ssctxData        = new SpamSumContext();

            Thread adlerThreadData     = new Thread(updateAdler);
            Thread crc16ThreadData     = new Thread(updateCRC16);
            Thread crc32ThreadData     = new Thread(updateCRC32);
            Thread crc64ThreadData     = new Thread(updateCRC64);
            Thread md5ThreadData       = new Thread(updateMD5);
            Thread ripemd160ThreadData = new Thread(updateRIPEMD160);
            Thread sha1ThreadData      = new Thread(updateSHA1);
            Thread sha256ThreadData    = new Thread(updateSHA256);
            Thread sha384ThreadData    = new Thread(updateSHA384);
            Thread sha512ThreadData    = new Thread(updateSHA512);
            Thread spamsumThreadData   = new Thread(updateSpamSum);

            adlerPacket     adlerPktData     = new adlerPacket();
            crc16Packet     crc16PktData     = new crc16Packet();
            crc32Packet     crc32PktData     = new crc32Packet();
            crc64Packet     crc64PktData     = new crc64Packet();
            md5Packet       md5PktData       = new md5Packet();
            ripemd160Packet ripemd160PktData = new ripemd160Packet();
            sha1Packet      sha1PktData      = new sha1Packet();
            sha256Packet    sha256PktData    = new sha256Packet();
            sha384Packet    sha384PktData    = new sha384Packet();
            sha512Packet    sha512PktData    = new sha512Packet();
            spamsumPacket   spamsumPktData   = new spamsumPacket();

            adler32ctxData.Init();
            adlerPktData.context = adler32ctxData;
            crc16ctxData.Init();
            crc16PktData.context = crc16ctxData;
            crc32ctxData.Init();
            crc32PktData.context = crc32ctxData;
            crc64ctxData.Init();
            crc64PktData.context = crc64ctxData;
            md5ctxData.Init();
            md5PktData.context = md5ctxData;
            ripemd160ctxData.Init();
            ripemd160PktData.context = ripemd160ctxData;
            sha1ctxData.Init();
            sha1PktData.context = sha1ctxData;
            sha256ctxData.Init();
            sha256PktData.context = sha256ctxData;
            sha384ctxData.Init();
            sha384PktData.context = sha384ctxData;
            sha512ctxData.Init();
            sha512PktData.context = sha512ctxData;
            ssctxData.Init();
            spamsumPktData.context = ssctxData;

            adlerPktData.data = data;
            adlerThreadData.Start(adlerPktData);
            crc16PktData.data = data;
            crc16ThreadData.Start(crc16PktData);
            crc32PktData.data = data;
            crc32ThreadData.Start(crc32PktData);
            crc64PktData.data = data;
            crc64ThreadData.Start(crc64PktData);
            md5PktData.data = data;
            md5ThreadData.Start(md5PktData);
            ripemd160PktData.data = data;
            ripemd160ThreadData.Start(ripemd160PktData);
            sha1PktData.data = data;
            sha1ThreadData.Start(sha1PktData);
            sha256PktData.data = data;
            sha256ThreadData.Start(sha256PktData);
            sha384PktData.data = data;
            sha384ThreadData.Start(sha384PktData);
            sha512PktData.data = data;
            sha512ThreadData.Start(sha512PktData);
            spamsumPktData.data = data;
            spamsumThreadData.Start(spamsumPktData);

            while (adlerThreadData.IsAlive || crc16ThreadData.IsAlive || crc32ThreadData.IsAlive ||
                   crc64ThreadData.IsAlive || md5ThreadData.IsAlive || ripemd160ThreadData.IsAlive ||
                   sha1ThreadData.IsAlive || sha256ThreadData.IsAlive || sha384ThreadData.IsAlive ||
                   sha512ThreadData.IsAlive || spamsumThreadData.IsAlive)
            {
            }

            List <ChecksumType> dataChecksums = new List <ChecksumType>();

            ChecksumType chk = new ChecksumType {
                type = ChecksumTypeType.adler32, Value = adler32ctxData.End()
            };

            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc16, Value = crc16ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc32, Value = crc32ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc64, Value = crc64ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.md5, Value = md5ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.ripemd160, Value = ripemd160ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha1, Value = sha1ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha256, Value = sha256ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha384, Value = sha384ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha512, Value = sha512ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.spamsum, Value = ssctxData.End()
            };
            dataChecksums.Add(chk);

            return(dataChecksums);
        }