Created
March 3, 2015 21:04
-
-
Save pudquick/8e27daa40e74ec2520ab to your computer and use it in GitHub Desktop.
XCode path mangling in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct, hashlib | |
def hashStringForPath(cls, path): | |
hash_path = [None] * 28; | |
md5_digest_hex = hashlib.md5(path).digest(); | |
first_value = struct.unpack('>Q', md5_digest_hex[:8])[0]; | |
second_value = struct.unpack('>Q', md5_digest_hex[8:])[0]; | |
counter = 13; | |
while counter >= 0: | |
hash_path[counter] = chr((first_value % 26) + ord('a')); | |
first_value = first_value / 26; | |
counter -= 1; | |
counter = 27; | |
while counter > 13: | |
hash_path[counter] = chr((second_value % 26) + ord('a')); | |
second_value = second_value / 26; | |
counter -= 1; | |
return ''.join(hash_path); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment