ZombieEllipses
I'm writing a Python script to do some work on my backups from TheBrain.

I've noticed that Thought Notes that contain links to other thoughts use values in the URL that can't directly be found anywhere else in the backup, so my current assumption is that these are hashed / encoded values of some kind.

How does TheBrain generate these values? I need to be able to decipher these back to the Thought Id value so I can honor these links in my output.
Quote
jupdike
If you have a long GUID string (like d6a0dd87-5892-5bb9-b097-bf44ef5464b0) you can convert it to and from these short URLs with code like this (unsupported, left as an exercise to the reader; this is C# code):

Code:
public static string ToShortGuid(this Guid newGuid) {
string modifiedBase64 = Convert.ToBase64String(newGuid.ToByteArray())
.Replace('+', '-').Replace('/', '_') // avoid invalid URL characters
.Substring(0, 22);
return modifiedBase64;
}

public static Guid ParseShortGuid(this string shortGuid) {
string base64 = shortGuid.Replace('-', '+').Replace('_', '/') + "==";
Byte[] bytes = Convert.FromBase64String(base64);
return new Guid(bytes);
}
Jared Updike
TheBrain Technologies
Engineering Team
Quote
ZombieEllipses
Strange. I feel like I'm close -- when converting from the GUID to what you call the ShortGuid, using Python, I can get part of the string to match, but not all of it.
Quote
ZombieEllipses
Ah, ok, solved. Difference in the way C# and Python natively order the elements in a GUID/UUID.
Quote

Add a Website Forum to your website.

Newsletter Signup  Newsletter        Visit TheBrain Blog   Blog       Follow us on Twitter   Twitter       Like Us on Facebook   Facebook         Circle Us on Google+  Google         Watch Us on Youtube  YouTube       

TheBrain Mind Map & Mindmapping Software     Download TheBrain Mind Mapping Software