-\feffusing System;
+\feff/**
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using System;
using System.Collections.Generic;
using System.Linq;
}
public ScryptHash256() : base() { }
- public ScryptHash256(byte[] bytes) : base(bytes) { }
- public ScryptHash256(IEnumerable<byte> bytes) : base(bytes) { }
+ public ScryptHash256(byte[] bytes, int offset = 0) : base(bytes, offset) { }
+ public ScryptHash256(IEnumerable<byte> bytes, int skip = 0) : base(bytes, skip) { }
+ public ScryptHash256(ScryptHash256 h) : base(h) { }
/// <summary>
/// Calculate scrypt hash and return new instance of ScryptHash256 class
/// <returns>Hashing result instance</returns>
public static ScryptHash256 Compute256(IEnumerable<byte> inputBytes)
{
- uint[] V = new uint[(131072 + 63) / sizeof(uint)];
+ var V = new uint[(131072 + 63) / sizeof(uint)];
- byte[] dataBytes = inputBytes.ToArray();
- byte[] keyBytes1 = CryptoUtils.PBKDF2_Sha256(128, dataBytes, dataBytes, 1);
- uint[] X = Interop.ToUInt32Array(keyBytes1);
+ var dataBytes = inputBytes.ToArray();
+ var keyBytes1 = CryptoUtils.PBKDF2_Sha256(128, dataBytes, dataBytes, 1);
+ var X = Interop.ToUInt32Array(keyBytes1);
uint i, j, k;
for (i = 0; i < 1024; i++)
xor_salsa8(ref X, 16, ref X, 0);
}
- byte[] xBytes = Interop.LEBytes(X);
- byte[] keyBytes2 = CryptoUtils.PBKDF2_Sha256(32, dataBytes, xBytes, 1);
+ var xBytes = Interop.LEBytes(X);
+ var keyBytes2 = CryptoUtils.PBKDF2_Sha256(32, dataBytes, xBytes, 1);
return new ScryptHash256(keyBytes2);
}