예제 #1
0
        internal static HashAlgorithm GetHashAlgorithm(Type type = null)
        {
            if (type == null)
            {
#if UNITY_2020_1_OR_NEWER
                // New projects on 2021.1 will default useSpookyHash to true
                // Upgraded projects will remain false until they choose to switch
                type = ScriptableBuildPipeline.useV2Hasher ? typeof(SpookyHash) : typeof(MD5);
#else
                type = typeof(MD5);
#endif
            }

            if (type == typeof(MD4))
            {
                return(MD4.Create());
            }
#if UNITY_2019_3_OR_NEWER
            if (type == typeof(SpookyHash))
            {
                return(SpookyHash.Create());
            }
#endif

            // TODO: allow user created HashAlgorithms?
            var alggorithm = HashAlgorithm.Create(type.FullName);
            if (alggorithm == null)
            {
                throw new NotImplementedException("Unable to create hash algorithm: '" + type.FullName + "'.");
            }
            return(alggorithm);
        }
예제 #2
0
        static HashAlgorithm GetHashAlgorithm(Type type)
        {
            if (type == typeof(MD4))
            {
                return(MD4.Create());
            }

            // TODO: allow user created HashAlgorithms?
            var alggorithm = HashAlgorithm.Create(type.FullName);

            if (alggorithm == null)
            {
                throw new NotImplementedException("Unable to create hash algorithm: '" + type.FullName + "'.");
            }
            return(alggorithm);
        }