Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net
- Imports System.Security.Cryptography
- Imports System.Text
- Namespace pwned_search ' namespace pwned_search {
- Class Program ' internal class Program {
- Public Shared Sub Main(args As String()) ' private static void Main(string[] args) { -> converted to public because program wont start otherwise
- Dim argtarget = Console.OutputEncoding ' var argtarget = Console.OutputEncoding;
- Console.InputEncoding = CSharpImpl.__Assign(argtarget, Encoding.UTF8) ' Console.InputEncoding = CSharpImpl.__Assign(ref argtarget, Encoding.UTF8);
- Console.Write("Enter the password to check: ") ' Console.Write("Enter the password to check: ");
- Dim plaintext = Console.ReadLine() ' var plaintext = Console.ReadLine();
- Dim sha As SHA1 = New SHA1CryptoServiceProvider() ' SHA1 sha = new SHA1CryptoServiceProvider();
- Dim Data = sha.ComputeHash(Encoding.UTF8.GetBytes(plaintext)) ' var Data = sha.ComputeHash(Encoding.UTF8.GetBytes(plaintext));
- Dim sBuilder = New StringBuilder() ' var sBuilder = new StringBuilder();
- Dim loopTo = Data.Length ' var loopTo = Data.Lenght;
- For i As Integer = 0 To loopTo - 1 ' for (int i = 0; i <= loopTo; i++) {
- sBuilder.Append(Data(i).ToString("x2")) ' sBuilder.Append(Data[i].ToString("x2"));
- Next ' }
- Dim result = sBuilder.ToString().ToUpper() ' Dim result = sBuilder.ToString().ToUpper();
- Console.WriteLine("The SHA-1 hash of " + plaintext + " is: " + result) ' Console.WriteLine("The SHA-1 hash of " + plaintext + " is: " + result);
- Dim url = "https://api.pwnedpasswords.com/range/" + result.Substring(0, 5) ' var url = "https://api.pwnedpasswords.com/range/" + result.Substring(0, 5);
- Dim request = WebRequest.Create(url) ' var request = WebRequest.Create(url);
- Dim response = request.GetResponse().GetResponseStream() ' var response = request.GetResponse().GetResponseStream();
- Dim reader = New StreamReader(response) ' var reader = new StreamReader(response);
- Dim hashToCheck = result.Substring(5) ' var hashToCheck = result.Substring(5);
- While True ' while (true) {
- Dim line = reader.ReadLine() ' var line = reader.ReadLine();
- If line = Nothing Then ' if (line == null) {
- Console.WriteLine("That password was not found.") ' Console.WriteLine("That password was not found.");
- Exit While ' break;
- End If ' }
- Dim parts = line.Split(":"c) ' var parts = line.Split(':');
- If parts(0) = hashToCheck Then ' if (parts[0] == hashToCheck) {
- Console.WriteLine("Password has been compromised -- DO NOT USE!") ' Console.WriteLine("Password has been compromised -- DO NOT USE!");
- Exit While ' break;
- End If ' }
- End While ' }
- Console.ReadKey() ' Console.ReadKey();
- End Sub ' }
- Private Class CSharpImpl ' private class CSharpImpl {
- Public Shared Function __Assign(Of T)(ByRef target As T, value As T) As T ' public static T __Assign(ref T target, T value) { --> Removed Obselete because I don't remember how that worked in VB lol
- target = value ' target = value;
- Return value ' return value;
- End Function ' }
- End Class ' }
- End Class ' }
- End Namespace ' }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement