![]() |
|
[Tutorial] [Text Tutorial] SHA-512 Encryption Handling of User Credentials [Text Tutorial] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5) +---- Thread: [Tutorial] [Text Tutorial] SHA-512 Encryption Handling of User Credentials [Text Tutorial] (/showthread.php?tid=5806502) |
[Text Tutorial] SHA-512 Encryption Handling of User Credentials [Text Tutorial] - KodaKing - Mar 2, 2018 The IDEcrashers Guide To Handling Salted Hash Algorithms for User Credentials in a Terminal Environment Ω-:[KodaKing]:-Ω The System.Security library maintains the System.Security.Cryptography nested class. When hashing encryptions from user input, this can assist in more descrete authorization handling. Code using System;When dealing with the Hash support it is necessary to determine the algorithm of choice. I will be using SHA-512 enencryption. For this lesson, I will stick to simply accessing an unprotected text file in /Documents for both the Username hash-table and the Password has-table. Within a Command Line interface we should first prompt the user for desired activity. Code System.Console.WriteLine("Welcome!");After we have set for the input, we can handle a new User Key-Pairing and output the pair to a text document. First we need to recieve out UTF-8 Username input and Password input from our new User. Code byte[] UsrData = Encoding.UTF8.GetBytes(Usr);Now convert the bytecode to a SHA512 hash. Code SHA512 shaWoah = new SHA512Managed();Having completed the first encryption hash, we can implement the same process for our password. Code byte[] PwdData = Encoding.UTF8.GetBytes(Pwd);After we have encrypted both the Username and Password, we may now transfer them to desired text file locations. You can determine any path for your text file. I will be converting my SHA 512 hash to a base64 string to provide a textual value. Code string InMy64 = Convert.ToBase64String(shaHash);Now, we can simply say nice words to the User. Code System.Console.WriteLine("Your Information Has Been Written To The File System!");For returning Users we will need to parse their input and authenticate. Code System.Console.WriteLine("Welcome! Please Input Your Username: ");Once again, to hash the encryption we must convert to bytecode from our UTF-8 input string. Code byte[] UsrData = Encoding.UTF8.GetBytes(Usr);To check the index of our key-pair, we will implement the StreamReader method and load our text file of Hashes to it. With a boolean operation we can check the relation of the indexes. Code int userindexglobal = 0;At this point, we will save the index location of the individual input credentials. Code UsrIndex:By passing the boolean we can validate the key-pair. Code Auth:If we are unable to verify the Username and Password combination, we will need to alert the User and determine a new life-cycle path. For such a task, I will display an error message to the console and relay back to the program's initialization. Code elseWith Authentication completed we get to deeper and more amusing things. |