Skip to content

Instantly share code, notes, and snippets.

@daCyuubi
Created April 7, 2019 13:32
Show Gist options
  • Save daCyuubi/aff09a1e6ec6693e4363ee1883d6abcc to your computer and use it in GitHub Desktop.
Save daCyuubi/aff09a1e6ec6693e4363ee1883d6abcc to your computer and use it in GitHub Desktop.
Nintendo Network password hash function in C#
public string HashPassword(int Pid, string Password)
{
MemoryStream Stream = new MemoryStream();
BinaryWriter Writer = new BinaryWriter(Stream);
Writer.Write(Pid);
Writer.Write(new byte[] { 0x02, 0x65, 0x43, 0x46 }); // Salt
Writer.Write(Encoding.ASCII.GetBytes(Password));
byte[] Hash = Sha256.ComputeHash(Stream.ToArray());
return BitConverter.ToString(Hash).Replace("-", string.Empty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment