public TokenManager() { _lastSecretGeneration = DateTime.MinValue; //in order to force the update _hash = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1).CreateHash(); _secret = CryptographicBuffer.GenerateRandom(10).ToArray(); _previousSecret = CryptographicBuffer.GenerateRandom(10).ToArray(); }
/// <summary> /// Initializes a new instance of the <see cref="DsaDigitalSignature"/> class. /// </summary> /// <param name="key">The DSA key.</param> public DsaDigitalSignature(DsaKey key) { if (key == null) throw new ArgumentNullException("key"); this._key = key; this._hash = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1).CreateHash(); }
public HashedInputStream(IInputStream stream) { if (stream == null) throw new ArgumentNullException("stream"); _stream = stream; _sha = HashAlgorithmProvider .OpenAlgorithm(HashAlgorithmNames.Sha256) .CreateHash(); }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param> protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this._isDisposed) { // If disposing equals true, dispose all managed // and unmanaged ResourceMessages. if (disposing) { // Dispose managed ResourceMessages. if (this._hash != null) { this._hash = null; } } // Note disposing has been done. this._isDisposed = true; } }
/// <summary> /// Initializes a new instance of the <see cref="RsaDigitalSignature"/> class. /// </summary> /// <param name="rsaKey">The RSA key.</param> public RsaDigitalSignature(RsaKey rsaKey) : base(new ObjectIdentifier(1, 3, 14, 3, 2, 26), new RsaCipher(rsaKey)) { this._hash = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1).CreateHash(); }
private void Init() { _hash = _provider.CreateHash(); }
int flake_encode_init() { int i, header_len; //if(flake_validate_params(s) < 0) ch_code = channels - 1; // find samplerate in table for (i = 1; i < 12; i++) { if (Settings.PCM.SampleRate == Flake.flac_samplerates[i]) { sr_code0 = i; break; } } // if not in table, samplerate is non-standard if (i == 12) throw new Exception("non-standard samplerate"); for (i = 1; i < 8; i++) { if (Settings.PCM.BitsPerSample == Flake.flac_bitdepths[i]) { bps_code = i; break; } } if (i == 8) throw new Exception("non-standard bps"); m_blockSize = m_settings.BlockSize != 0 ? m_settings.BlockSize : select_blocksize(Settings.PCM.SampleRate, eparams.block_time_ms); // set maximum encoded frame size (if larger, re-encodes in verbatim mode) if (channels == 2) max_frame_size = 16 + ((m_blockSize * (Settings.PCM.BitsPerSample + Settings.PCM.BitsPerSample + 1) + 7) >> 3); else max_frame_size = 16 + ((m_blockSize * channels * Settings.PCM.BitsPerSample + 7) >> 3); if (_IO.CanSeek && eparams.do_seektable && sample_count > 0) { int seek_points_distance = Settings.PCM.SampleRate * 10; int num_seek_points = 1 + sample_count / seek_points_distance; // 1 seek point per 10 seconds if (sample_count % seek_points_distance == 0) num_seek_points--; seek_table = new SeekPoint[num_seek_points]; for (int sp = 0; sp < num_seek_points; sp++) { seek_table[sp].framesize = 0; seek_table[sp].offset = 0; seek_table[sp].number = sp * seek_points_distance; } } // output header bytes header = new byte[m_settings.Padding + 1024 + (seek_table == null ? 0 : seek_table.Length * 18)]; header_len = write_headers(); // initialize CRC & MD5 if (_IO.CanSeek && m_settings.DoMD5) md5 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5).CreateHash(); if (m_settings.DoVerify) { verify = new FlakeReader(Settings.PCM); verifyBuffer = new int[Flake.MAX_BLOCKSIZE * channels]; } frame_buffer = new byte[max_frame_size]; return header_len; }
public void Clear() { _hash = _hasher.CreateHash(); }
/// <summary> /// Initializes a new instance of the <see cref="MailKit.Security.KeyedHashAlgorithm"/> class. /// </summary> /// <remarks> /// Creates a new keyed hash algorithm context. /// </remarks> /// <param name="algorithm">The MAC algorithm name.</param> /// <param name="key">The secret key.</param> protected KeyedHashAlgorithm (string algorithm, byte[] key) { var mac = MacAlgorithmProvider.OpenAlgorithm (algorithm); var buf = CryptographicBuffer.CreateFromByteArray (key); hmac = mac.CreateHash (buf); }
public void Initialize () { var buffer = CryptographicBuffer.CreateFromByteArray (Key); algorithm = MacAlgorithmProvider.OpenAlgorithm (MacAlgorithmNames.HmacMd5); hash = algorithm.CreateHash (buffer); }