001package net.minecraft.util; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import java.math.BigInteger; 006import java.security.MessageDigest; 007import java.security.NoSuchAlgorithmException; 008 009@SideOnly(Side.CLIENT) 010public class MD5String 011{ 012 /** The salt prepended to the string to be hashed */ 013 private String salt; 014 015 public MD5String(String par1Str) 016 { 017 this.salt = par1Str; 018 } 019 020 /** 021 * Gets the MD5 string 022 */ 023 public String getMD5String(String par1Str) 024 { 025 try 026 { 027 String s1 = this.salt + par1Str; 028 MessageDigest messagedigest = MessageDigest.getInstance("MD5"); 029 messagedigest.update(s1.getBytes(), 0, s1.length()); 030 return (new BigInteger(1, messagedigest.digest())).toString(16); 031 } 032 catch (NoSuchAlgorithmException nosuchalgorithmexception) 033 { 034 throw new RuntimeException(nosuchalgorithmexception); 035 } 036 } 037}