public HashAdapter(IHash a_hash) : base(a_hash.HashSize, a_hash.BlockSize) { Debug.Assert(a_hash != null); m_hash = a_hash; }
/// <summary> /// Initialises a new instance of the <see cref="RecoverPassword"/> class. /// </summary> /// <param name="log">Logging module</param> /// <param name="memberDataAccess">Member data access</param> /// <param name="emailSender">Email sender</param> /// <param name="hash">Password hasher</param> public RecoverPassword(ILogger log, IMemberDataAccess memberDataAccess, IEmailSender emailSender, IHash hash) { this.log = log; this.memberDataAccess = memberDataAccess; this.emailSender = emailSender; this.hash = hash; }
public Worker(int threadCount, int blockLength, IHash hasher, FileStream stream) { mainThread = Thread.CurrentThread; this.threadCount = threadCount; this.stream = stream; this.hasher = hasher; this.blockLength = blockLength; threads = new List<Thread>(threadCount); for (int i = 0; i < threadCount; ++i) { var b = new Buffer(); b.raw = new byte[blockLength]; bufferQueue.AddToQueue(b); } blockCount = stream.Length / blockLength; if (stream.Length % blockLength != 0) { blockCount++; } Console.CancelKeyPress += new ConsoleCancelEventHandler(Cancel); }
public void Init(IHash fileData, bool force) { int fByte1 = 127; // fmask - byte1 (old 120 Added other episodes) int fByte2 = 248; // old 72 fmask - byte2 (Added FileSize, SHA1, MD5) int fByte3 = 255; // fmask - byte3 int fByte4 = 249; // fmask - byte4 int fByte5 = 254; // fmask - byte5 int aByte1 = 0; // amask - byte1 int aByte2 = 0; // amask - byte2 int aByte3 = 252; // amask - byte3 old 236 Added Kanji name int aByte4 = 192; // amask - byte4 this.fileData = fileData; this.forceRefresh = force; commandID = fileData.Info; // 220 FILE572794|6107|99294|2723|c646d82a184a33f4e4f98af39f29a044|8452c4bf|high|HDTV|Vorbis (Ogg Vorbis)|148|H264/AVC|1773|1280x720|mkv|1470||1239494400|2|The Day It Began|Hajimari no Hi|712|14|Eclipse Productions|Eclipse commandText = "FILE size=" + fileData.FileSize.ToString(); commandText += "&ed2k=" + fileData.ED2KHash; commandText += string.Format("&fmask={0}{1}{2}{3}{4}", fByte1.ToString("X").PadLeft(2, '0'), fByte2.ToString("X").PadLeft(2, '0'), fByte3.ToString("X").PadLeft(2, '0'), fByte4.ToString("X").PadLeft(2, '0'), fByte5.ToString("X").PadLeft(2, '0')); commandText += string.Format("&amask={0}{1}{2}{3}", aByte1.ToString("X").PadLeft(2, '0'), aByte2.ToString("X").PadLeft(2, '0'), aByte3.ToString("X").PadLeft(2, '0'), aByte4.ToString("X").PadLeft(2, '0')); }
public SpeedTestDataSourceRow(IHash a_hashFunction) : base(a_hashFunction) { BytesPerCycle = "?"; BytesSpeed = "?"; ByteSpeed = "?"; StringSpeed = "?"; CharsSpeed = "?"; ShortsSpeed = "?"; UShortsSpeed = "?"; IntsSpeed = "?"; UIntsSpeed = "?"; LongsSpeed = "?"; ULongsSpeed = "?"; FloatsSpeed = "?"; DoublesSpeed = "?"; ByteSpeed = "?"; CharSpeed = "?"; ShortSpeed = "?"; UShortSpeed = "?"; IntSpeed = "?"; UIntSpeed = "?"; LongSpeed = "?"; ULongSpeed = "?"; FloatSpeed = "?"; DoubleSpeed = "?"; }
public HashAlgorithmWrapper(IHash a_hash) { Debug.Assert(a_hash != null); m_hash = a_hash; HashSizeValue = a_hash.HashSize * 8; }
public SettingsController(IUserService userService, IAuthProvider authProvider, ILocationService locationService, IHash hash) { _userService = new UserServiceClient(); _authProvider = authProvider; _locationService = new LocationServiceClient(); _hash = hash; }
internal HMACNotBuildInAdapter(IHash a_underlyingHash) : base(a_underlyingHash.HashSize, a_underlyingHash.BlockSize) { m_hash = a_underlyingHash; m_key = new byte[0]; m_ipad = new byte[m_hash.BlockSize]; m_opad = new byte[m_hash.BlockSize]; }
public static IHMAC CreateHMAC(IHash a_hash) { if (a_hash is IHMAC) { return((IHMAC)a_hash); } return(new HMACNotBuildInAdapter(a_hash)); }
public Sha3SpeedBenchmark() { this.data = new byte[N]; new Random(42).NextBytes(this.data); this.sha3_256 = new Sha3_256(); this.sha3_384 = new Sha3_384(); this.sha3_512 = new Sha3_512(); }
public AuthenticationDomain( IDatabaseUnitOfWork database, IHash hash, IJsonWebToken jsonWebToken) { Database = database; Hash = hash; JsonWebToken = jsonWebToken; }
public HashTable(IHash hash) { list = new List[n]; for (int i = 0; i < n; ++i) { list[i] = new List(); } this.hash = hash; }
public IEnumerable <IHash> GetDataConflict() { IHash <IAccount> a = null; IHash <IAccount> b = null; yield return(a); yield return(b); }
public void VerifyHMACSHA512Hash() { string valueToHash = "qwerty"; string salt = "/KzcYC/PC4c4ucgriabmhA=="; string expectedValue = "EYxkddpZRM2KTR+fjT8G9jA2bYtjUMSrr8CfOgWyI2VXUYU3LrPPC2F9kVx7mRoGR0YaDEZppXXvkgCymDKWJQ=="; IHash hash = HMACHashDelegate.HMACHash(valueToHash, Convert.FromBase64String(salt), KeyDerivationPrf.HMACSHA512); Assert.True(hash.Hash == expectedValue); }
public void VerifyHMACSHA256Hash() { string valueToHash = "qwerty"; string salt = "GPQ/DRGs6RSYjOh1EE1CZwKNCqCP8Zhb4DAhczEQYpE="; string expectedValue = "eY+j2PXHewxRiVrz+ngCEfwHXqsmF151Y3M+xrL2HlM="; IHash hash = HMACHashDelegate.HMACHash(valueToHash, Convert.FromBase64String(salt), KeyDerivationPrf.HMACSHA256); Assert.True(hash.Hash == expectedValue); }
public void VerifyHMACSHA1Hash() { string valueToHash = "qwerty"; string salt = "/KzcYC/PC4c4ucgriabmhA=="; string expectedValue = "s+QcBH+1K1kIPk2GnGMPMJFzBVA="; IHash hash = HMACHashDelegate.HMACHash(valueToHash, Convert.FromBase64String(salt), KeyDerivationPrf.HMACSHA1); Assert.True(hash.Hash == expectedValue); }
public void WriteHash(IHash hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (GetIsInNodeSet()) { UTF8Encoding utf8 = new UTF8Encoding(false); byte[] rgbData = utf8.GetBytes(ParserUtils.EscapeTextData(Value)); hash.BlockUpdate(rgbData, 0, rgbData.Length); } }
public static byte[] GetTransactionKeyHash(int forValue = 0) { IHash hash = HashLib.HashFactory.Hash128.CreateMurmur3_128(); byte[] originBytes = BitConverter.GetBytes(forValue); byte[] hashBytes = hash.ComputeBytes(originBytes).GetBytes(); return(hashBytes); }
public static byte[] GetDefaultHash(int forValue = 0) { IHash hash = HashLib.HashFactory.Crypto.CreateSHA256(); byte[] hashOrigin = BitConverter.GetBytes(forValue); byte[] hashBytes = hash.ComputeBytes(hashOrigin).GetBytes(); return(hashBytes); }
public void WriteHash(IHash hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (IsInNodeSet && docPos == DocPosition.InRootElement) { UTF8Encoding utf8 = new UTF8Encoding(false); byte[] rgbData = utf8.GetBytes(Utils.EscapeWhitespaceData(Value)); hash.BlockUpdate(rgbData, 0, rgbData.Length); } }
internal HashToHashAlgorithmAdapter(IHash hash) { _hash = hash != null ? hash.Clone() : throw new ArgumentNullException(nameof(hash)); HashSizeValue = _hash.HashSize * 8; Initialize(); }
public Quark() { blake512 = HashFactory.Crypto.SHA3.CreateBlake512(); bmw512 = HashFactory.Crypto.SHA3.CreateBlueMidnightWish512(); groestl512 = HashFactory.Crypto.SHA3.CreateGroestl512(); skein512 = HashFactory.Crypto.SHA3.CreateSkein512_Custom(); jh512 = HashFactory.Crypto.SHA3.CreateJH512(); keccak512 = HashFactory.Crypto.SHA3.CreateKeccak512(); }
public AuthenticationService( IProfile profile, IHash hash, IOtpService otpService) { _profile = profile; _hash = hash; _otpService = otpService; }
public SignInService ( IHash hash, IJsonWebToken jsonWebToken ) { Hash = hash; JsonWebToken = jsonWebToken; }
public AuthenticationService() { _profile = new ProfileDao(); _hash = new Sha256Adapter(); _otpService = new OtpService(); _notification = new SlackAdapter(); _failedCounter = new FailedCounter(); _logger = new NLogAdapter(); }
public AuthenticationService(IProfile profile, IHash hash, IOtpService otpService, INotification notification, IFailedCounter failedCounter, ILogger logger) { _profile = profile; _hash = hash; _otpService = otpService; _notification = notification; _failedCounter = failedCounter; _logger = logger; }
public Phi2() { cubehash512 = HashFactory.Crypto.SHA3.CreateCubeHash512(); jh512 = HashFactory.Crypto.SHA3.CreateJH512(); echo512 = HashFactory.Crypto.SHA3.CreateEcho512(); skein512 = HashFactory.Crypto.SHA3.CreateSkein512_Custom(); lyra2 = new Lyra2Broken.Lyra2(); gost = new Gost(); }
public HashTable(IHash hash) { this.hash = hash; list = new List[hashConstant]; for (int i = 0; i < hashConstant; ++i) { list[i] = new List(); } }
public static byte[] GetPowHash(int forValue = 0) { IHash hash = HashLib.HashFactory.Crypto.CreateTiger_4_192(); byte[] powHashOrigin = BitConverter.GetBytes(forValue); byte[] powHash = hash.ComputeBytes(powHashOrigin).GetBytes(); return(powHash); }
public UserDomainService ( IHash hash, IJsonWebToken jsonWebToken ) { Hash = hash; JsonWebToken = jsonWebToken; }
public void CompressAndWritePassWordHash(string dirPath) { ICompress zip = CreateZipper(dirPath); zip.ZipDirectories(); HashFile = Factory.CreateHashFile(dirPath); HashFile.TransfromBase64StringAndWrite(Password.Salt, Password.Hash); Md5 = CreateHasher(Path.GetFullPath(dirPath)); }
/// <summary> /// Initialises a new instance of the <see cref="SessionController"/> class. /// </summary> /// <param name="log">Logging module</param> /// <param name="memberDataAccess">Member data access</param> /// <param name="sessionDataAccess">Session data access</param> /// <param name="hash">Password hash</param> /// <param name="timeout">Timeout</param> public SessionController(ILogger log, IMemberDataAccess memberDataAccess, ISessionDataAccess sessionDataAccess, IHash hash, TimeSpan timeout) { this.log = log; this.memberDataAccess = memberDataAccess; this.sessionDataAccess = sessionDataAccess; this.hash = hash; this.timeout = timeout; sessions = new Dictionary<Guid, Session>(); locker = new ReaderWriterLockSlim(); }
internal HMACNotBuildInAdapter(IHash a_underlyingHash) : base(a_underlyingHash.HashSize, a_underlyingHash.BlockSize) { Debug.Assert(a_underlyingHash != null); m_hash = a_underlyingHash; m_ipad = new byte[m_hash.BlockSize]; m_opad = new byte[m_hash.BlockSize]; }
/// <summary> /// Signs a hash value. /// </summary> /// <param name="hash">The hash.</param> /// <returns>The signature.</returns> /// <exception cref="ArgumentNullException">Thrown if /// <paramref name="hash"/> is null.</exception> public ISignature Sign(IHash hash) { if (hash == null) { throw new ArgumentNullException(nameof(hash)); } return(new RsaSignature( signerCertificateHash: this.DeriveCertificate().Hash, signature: this.rsa.SignHash(hash.Hash.ToArray(), hash.Name, RSASignaturePadding.Pkcs1))); }
private static bool ValidateHashes(IHash hash1, IHash hash2) { Type hash1Type = hash1.GetType(); Type hash2Type = hash2.GetType(); int hash1Length = hash1.Stream.Count(); int hash2Length = hash2.Stream.Count(); return(hash1Type.Equals(hash2Type) && hash1Length == hash2Length); }
private void WriteEncryptedBytes(string fileName, byte[] fileBytes) { Encryptor = Factory.CreateEncryptor(Password); byte[] Encrypted = Encryptor.Encrypt(fileBytes); File.WriteAllBytes(fileName, Encrypted); Md5 = CreateHasher(fileName); string hashString = Md5.BeginHashing(); HashFile.TransformStringAndWrite(fileName, hashString); }
/// <summary> /// Constructor of hash table /// </summary> /// <param name="length">Length of hash table</param> /// <param name="hash">Chosen hash function</param> public HashTable(int length, IHash hash) { this.length = length; buckets = new List[length]; for (int i = 0; i < length; ++i) { buckets[i] = new List(); } this.hash = hash; }
public void HashTest4() { //获取一个md5签名对象 IHash md5hash = Crypto.Hash(HashFlag.MD5); var md5value = md5hash.SignData("mypassword"); //获取一个sha1签名对象 IHash sha1hash = Crypto.Hash(HashFlag.SHA1); var sha1value = md5hash.SignData("mypassword"); }
protected void DoComputeBlake2(IHash hashInstance, byte[] data) { hashInstance.Initialize(); hashInstance.TransformBytes(data); var result = hashInstance.TransformFinal().GetBytes(); ActualString = Converters.ConvertBytesToHexString(result); AssertAreEqual(ExpectedString, ActualString); }
public UserDomain( IDatabaseUnitOfWork databaseUnitOfWork, IHash hash, IJsonWebToken jsonWebToken ) : base(databaseUnitOfWork) { Hash = hash; JsonWebToken = jsonWebToken; }
protected TestData(IHash a_hash, List<byte[]> a_keys) { m_hash = a_hash; if (a_keys != null) m_keys = a_keys; if (m_keys.Count != 0) Debug.Assert(a_hash is IWithKey); }
public void Setup() { _profile = Substitute.For <IProfile>(); _hash = Substitute.For <IHash>(); _otpService = Substitute.For <IOtpService>(); _notification = Substitute.For <INotification>(); _failedCounter = Substitute.For <IFailedCounter>(); _logger = Substitute.For <ILogger>(); _authenticationService = new AuthenticationService(_profile, _hash, _otpService, _notification, _failedCounter, _logger); }
public void Init(IHash fileData, AniDBFileStatus FileStatus) { FileData = fileData; commandID = fileData.Info; commandText = "MYLISTADD size=" + fileData.FileSize.ToString(); commandText += "&ed2k=" + fileData.ED2KHash; commandText += "&viewed=0"; commandText += "&state=" + (int)FileStatus; }
/// <summary> /// Initialises a new instance of the <see cref="AccountController"/> class. /// </summary> /// <param name="log">Logging module</param> /// <param name="memberDataAccess">Member data access</param> /// <param name="sessionController">Session controller</param> /// <param name="forgotPassword">Forgot password</param> /// <param name="dealDataAccess">Deal data access</param> /// <param name="hash">Hasher</param> /// <param name="emailSender">Email sender</param> /// <param name="currentUser">Current user</param> public AccountController(ILogger log, IMemberDataAccess memberDataAccess, ISessionController sessionController, IRecoverPassword forgotPassword, IDealDataAccess dealDataAccess, IHash hash, IEmailSender emailSender, ICurrentUser currentUser) { this.log = log; this.memberDataAccess = memberDataAccess; this.sessionController = sessionController; this.forgotPassword = forgotPassword; this.dealDataAccess = dealDataAccess; this.hash = hash; this.emailSender = emailSender; userName = currentUser.GetCurrentUser(); }
public AvalancheTestDataSourceRow(IHash a_hashFunction) : base(a_hashFunction) { BmpByte = LoadBitmap("Byte"); BmpUShort = LoadBitmap("UShort"); BmpUInt = LoadBitmap("UInt"); BmpULong = LoadBitmap("ULong"); BmpDouble = LoadBitmap("Double"); Bmp128 = LoadBitmap("128"); Bmp256 = LoadBitmap("256"); BmpString = LoadBitmap("String"); }
protected void Test(IHash a_hash) { TestHashSize(a_hash); TestInitialization(a_hash); TestComputeTransforms(a_hash); TestMultipleTransforms(a_hash); TestHashResult(a_hash); TestHashStream(a_hash, 26); TestHashStream(a_hash, Hash.BUFFER_SIZE); TestAgainstTestFile(a_hash); TestHashFile(a_hash, 26); TestHashFile(a_hash, Hash.BUFFER_SIZE); TestFastHash32(a_hash); TestKey(a_hash); }
internal void TestAgainstBaseImplementationArrayType(IHash a_baseHashFunction, IHash a_hash) { for(int j = 0; j < 2; j++) { for(int i = 9; i <= (a_hash.BlockSize * 3 + 1); i++) { byte[] v = m_random.NextBytes(i); HashResult h1 = a_baseHashFunction.ComputeBytes(v); HashResult h2 = a_hash.ComputeBytes(v); Assert.AreEqual(h1, h2, String.Format("{0}, {1}", a_hash.Name, i)); } } }
/*public void Init(IHash fileData, bool watched) { FileData = fileData; IsWatched = watched; commandID = fileData.Info; commandText = "MYLISTADD size=" + fileData.FileSize.ToString(); commandText += "&ed2k=" + fileData.ED2KHash; commandText += "&viewed=" + (IsWatched ? "1" : "0"); //viewed commandText += "&edit=1"; }*/ public void Init(IHash fileData, bool watched, DateTime? watchedDate, bool isEdit, AniDBFileStatus? fileState) { FileData = fileData; IsWatched = watched; commandID = fileData.Info; commandText = "MYLISTADD size=" + fileData.FileSize.ToString(); commandText += "&ed2k=" + fileData.ED2KHash; commandText += "&viewed=" + (IsWatched ? "1" : "0"); //viewed if (fileState.HasValue) commandText += "&state=" + (int) fileState; if (watchedDate.HasValue) commandText += "&viewdate=" + Utils.GetAniDBDateAsSeconds(watchedDate.Value).ToString(); if (isEdit) commandText += "&edit=1"; }
public Server() { connector = new Connector(); connections = new List<IConnection>(); commandExecutor = new CommandExecutor( new PingCommand(), new EchoCommand(), new ClientCommand(), new InfoCommand(), new ConfigCommand(), new ExistsCommand(), new DelCommand(), new GetCommand(), new SetCommand() ); hash = new Hash(); }
public CommunicationProtocol(ICoderWithSettings coder, IHash coderHash, ICoderWithSettings decoder, IHash decoderHash) { _coder = coder; _decoder = decoder; _coderHash = coderHash; _decoderHash = decoderHash; ValidationKey = new ValidationKey(); CipherSettings = new CipherSettingsViewModel(); _coder.CurrentSatate = CipherSettings.InitBytesRegister; var sboxesArray = CipherSettings.SboxesArray; _coder.Sboxes = sboxesArray; _decoder.Sboxes = sboxesArray; getSboxesBytes(sboxesArray); CipherSettings.PropertyChanged += cipherSettingsViewModelOnPropertyChanged; }
protected void TestAgainstTestFile(IHash a_hash, TestData a_test_data = null) { if (a_test_data == null) a_test_data = TestData.Load(a_hash); for (int i = 0; i < a_test_data.Count; i++) { string output_array = Converters.ConvertBytesToHexString(a_test_data.GetHash(i)); if (a_test_data.GetRepeat(i) != 1) continue; if (a_hash is IWithKey) (a_hash as IWithKey).Key = a_test_data.GetKey(i); Assert.AreEqual(output_array, a_hash.ComputeBytes(a_test_data.GetData(i)).ToString(), String.Format("{0}, {1}", a_hash.Name, i)); } }
protected void Test(IHash a_hash, IHash a_base) { if(a_base == null) { TestAgainstTestFile(a_hash, new TestData(a_hash)); } else { TestAgainstBaseImplementationValueType(a_base, a_hash); } TestMultipleTransformsValueType(a_hash, a_hash); TestHashStreamValueType(a_hash, a_hash); TestHashFileValueType(a_hash, a_hash); TestHashSize(a_hash); if(a_base != null) TestCompatibilityWithBaseClass(a_hash, a_base); TestInitialization(a_hash); TestResult(a_hash); }
public Hmac(IHash hash) { this.hash = hash; }
public Fugue() { _hasher = HashFactory.Crypto.SHA3.CreateFugue256(); Multiplier = (UInt32)Math.Pow(2, 8); }
public Keccak() { _hasher = HashFactory.Crypto.SHA3.CreateKeccak256(); Multiplier = (UInt32)Math.Pow(2, 8); }
public Groestl() { _hasher = HashFactory.Crypto.SHA3.CreateGroestl512(); Multiplier = (UInt32)Math.Pow(2, 8); }
public CalculatorDataSourceRow(IHash a_hashFunction) : base(a_hashFunction) { }
public static IHMAC CreateHMAC(IHash a_hash) { if (a_hash is IHMAC) return (IHMAC)a_hash; else if (a_hash is IHasHMACBuildIn) { HashCryptoBuildIn h = (HashCryptoBuildIn)a_hash; return new HMACBuildInAdapter(h.GetBuildHMAC(), h.BlockSize); } return new HMACNotBuildInAdapter(a_hash); }
public static System.Security.Cryptography.HashAlgorithm HashToHashAlgorithm(IHash a_hash) { return new HashAlgorithmWrapper(a_hash); }