Ejemplo n.º 1
0
        public Chunker(Stream stream, HasherType type, uint significantHashBits)
        {
            //significantBitsMask = (uint)Math.Pow(2, significantHashBits);
            for (var i = 0; i < significantHashBits; i++)
            {
                significantBitsMask = (uint)((significantBitsMask << 1) + 1);
            }

            copyingStream = new CopyingStream(stream);
            this.hasher   = AbstractRollingHasher.createInstance(type, copyingStream, WINDOW_SIZE);
        }
Ejemplo n.º 2
0
        public static AbstractRollingHasher createInstance(HasherType type, Stream stream, int windowSize)
        {
            switch (type)
            {
            case HasherType.BuzHash:
                return(new BuzHashRollingHasher(stream, windowSize));

            default:
                return(null);
            }
        }
Ejemplo n.º 3
0
        public IHasher CreateHasher(HasherType hasherType)
        {
            switch (hasherType)
            {
            case HasherType.None: return(new NotHasher());

            case HasherType.MD5: return(new MDFive128BitHasher());

            case HasherType.SHA1: return(new Sha160BitHasher());

            case HasherType.SHA256: return(new Sha256BitHasher());

            case HasherType.SHA512: return(new Sha512BitHasher());

            default:
                throw new ArgumentOutOfRangeException($"Unable to create IHasher for HasherType: '{hasherType}'");
            }
        }
Ejemplo n.º 4
0
 public Hasher(HasherType typ)
 {
     hasherType = typ;
 }
Ejemplo n.º 5
0
 public Chunker(byte[] data, HasherType type, uint significantHashBits)
     : this(new MemoryStream(data), type, significantHashBits)
 {
 }
Ejemplo n.º 6
0
 public Chunker(Stream stream, HasherType type)
     : this(stream, type, DEFAULT_SIGNIFICANT_BITS_NUMBER)
 {
 }
Ejemplo n.º 7
0
 public Chunker(byte[] data, HasherType type)
     : this(new MemoryStream(data), type, DEFAULT_SIGNIFICANT_BITS_NUMBER)
 {
 }
Ejemplo n.º 8
0
 public Hasher(HasherType typ)
 {
     hasherType = typ;
 }