Notifications
                
            
                Clear all
    
            
        [Closed] Does SHA1 exist in Maxscript?
                             3 Replies                        
                    
                        
                        1 Reply
                    
                    check encrypted files [color=white]and encrypted scripts [/color]in MXS help.
also you can use dotnet for any “hash” things. You can find the snippet in dotnet + MXS section
Nov 18, 2009 4:42 pm
                      Thank you. I got it.
i used System.Security.Cryptography.SHA1 from dot net. its OK
Nov 18, 2009 4:42 pm
                      Check this out:
(
	function getTextHash HashMethod SourceText =
	(
		case tolower(HashMethod) of
		(
			"sha1" : hMethod = dotNetObject "System.Security.Cryptography.SHA1CryptoServiceProvider"
			default : hMethod = dotNetObject "System.Security.Cryptography.MD5CryptoServiceProvider"
		)
		ue =  dotNetObject "System.Text.UnicodeEncoding"
		bytesToHash = ue.GetBytes SourceText
		
		hash = hMethod.ComputeHash bytesToHash
		buff = dotnetObject "System.Text.StringBuilder"
		SysString = dotNetClass "System.String"
		for hashbyte in hash do
		(
			buff.Append (SysString.Format "{0:X2}" hashByte)
		)	
		buff.ToString()
	)
	
	function getFileHash HashMethod SourceFile =
	(
		case tolower(HashMethod) of
		(
			"sha1" : hMethod = dotNetObject "System.Security.Cryptography.SHA1CryptoServiceProvider"
			default : hMethod = dotNetObject "System.Security.Cryptography.MD5CryptoServiceProvider"
		)
		f = dotNetObject "System.IO.FileStream" SourceFile (dotNetClass "System.IO.FileMode").Open (dotNetClass "System.IO.FileAccess").Read (dotNetClass "System.IO.FileShare").Read 8192
		hMethod.ComputeHash f
		hash = hMethod.Hash
		f.Close()
		buff = dotnetObject "System.Text.StringBuilder"
		byte = dotNetClass "System.Byte"
		SysString = dotNetClass "System.String"
		for hashByte in hash do
		(
			buff.Append (SysString.Format "{0:X2}" hashByte)
		)
		buff.ToString()
	)
	clearlistener()
	md5Text=getTextHash "MD5" "Hello World"
	sha1Text=getTextHash "SHA1" "Hello World"
	md5File=getFileHash "MD5" @"C:	est.txt"
	sha1File=getFileHash "SHA1" @"C:	est.txt"
	
	print ("MD5 text checksum: " + md5Text)
	print ("SHA1 text checksum: " + sha1Text)
	print ("MD5 file checksum: "+ md5File)
	print ("SHA1 file checksum: " + sha1File)
	undefined
)
http://forums.cgsociety.org/showpost.php?p=6174428&postcount=392
Cheers