Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by frostrixz · May 05, 2021 at 09:56 PM · assetbundlecacheassetbundlescachingcryptography

How Unity Generates Cache Hash For AssetBundles

I am looking into the technical aspect to how Unity generates the cache name for an asset bundle.

For example, my game caches an asset bundle of URL, Hash128 and CRC to a bundle of Example_Game/b2ee2b99701af83199d653e4 using WWW.LoadFromCacheOrDownload. How does Unity generate the cache's name from this data? (the "b2ee2b99701af83199d653e4" file name).

In summary, what cryptographic algorithm does Unity use internally to generate this hash for the file name, and how can we recreate the hash from this data ourselves?

For reference, the version of Unity I'm using is Unity 4.6 - hence the old LoadFromCacheOrDownload method that is being used.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · May 05, 2021 at 10:44 PM

Have you actually checked the documentation on the Hash128 class?

The hash algorithm used to compute Hash128 values is SpookyHash V2. Note that while this hash algorithm is quite fast to compute and has good hash distribution qualities, it is not a cryptographic hash function.

They linked the wikipedia article for the SpookyHash V2. Though you should be able to find various implementations of that algorithm in the wild.


About what they base the hash on for the cached files, I just don't know since I never used the cache functionality of the WWW class. Though my guess would be that it may be just the request URL Though if the hash is actually used to distinguish the actual content, it's probably just the content hashed.


Once you have an implementation of the hash algorithm up and working, I would recommend to first check if it produces the same hash as Unity's class. If it does you can simply try hashing various things related to the cached file to see if you can produces the same hash.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image frostrixz · May 06, 2021 at 01:17 AM 0
Share

I did check the Hash128 class, but they did not have any documentation prior to the 2020.1 documentation. As I was looking for references to Unity 4.6, I was worried that the algorithm may have changed between versions.

I will try hash it through the algorithms online and compare them.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

121 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Caching Unity Web Request downloaded Asset Bundles denied by iOS 0 Answers

Addressable Assets Cache 0 Answers

Why was the method overload for Caching.IsVersionCached that accepts an integer instead of a Hash128 made obsolete if UnityWebRequest's GetAssetBundle method still takes an integer version number as input? 0 Answers

Cannot download large assetbundle with WWW.LoadFromCacheOrDownload on old iOS device 1 Answer

How to add an AssetBundle into cache from a file 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges