Last active
December 16, 2015 18:40
-
-
Save alecnunn/5479849 to your computer and use it in GitHub Desktop.
A basic benchmark miner for BlooCoin written in Visual Basic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Module Module1 | |
| Sub Main() | |
| mine("kNTny") | |
| Console.Read() | |
| End Sub | |
| Dim winning As String = "0000000" | |
| Sub mine(ByVal seed As String) | |
| Dim num As Integer = 0 | |
| Dim found As Boolean | |
| While found = False | |
| Dim attempt As String = seed & num | |
| Try | |
| Dim hash As String = SHAHasher.HexHash(attempt) | |
| If (hash.StartsWith(winning)) Then | |
| Console.ForegroundColor = ConsoleColor.Green | |
| Console.WriteLine(attempt) | |
| Console.WriteLine(hash.ToLower) | |
| found = True | |
| Else | |
| 'Console.ForegroundColor = ConsoleColor.Red | |
| 'Console.WriteLine(attempt) | |
| End If | |
| Catch ex As Exception | |
| End Try | |
| num = num + 1 | |
| End While | |
| End Sub | |
| Public Class SHAHasher | |
| Private Sub New() | |
| 'For instantiation | |
| End Sub | |
| Public Shared Function HexHash(ByVal clearText As String) As String | |
| Dim hashedBytes As Byte() = computeHash(clearText) | |
| Dim hexString As New System.Text.StringBuilder() | |
| For i As Int32 = 0 To hashedBytes.Length - 1 | |
| hexString.Append(hashedBytes(i).ToString("X2")) | |
| Next | |
| Return hexString.ToString() | |
| End Function | |
| Private Shared Function computeHash(ByVal clearText As String) As Byte() | |
| Dim encoder As New Text.UTF8Encoding() | |
| Dim sha512hasher As New System.Security.Cryptography.SHA512Managed() | |
| Return sha512hasher.ComputeHash(encoder.GetBytes(clearText)) | |
| End Function | |
| End Class | |
| End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment