# Snippet to decode base64 UUIDs in .proj files

**URL:** <https://forum.inductiveautomation.com/t/snippet-to-decode-base64-uuids-in-proj-files/17046>\
**Category:** Ignition\
**Created:** [February 20, 2018, 10:14am UTC](https://forum.inductiveautomation.com/t/snippet-to-decode-base64-uuids-in-proj-files/17046 "2018-02-20T10:14:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [February 20, 2018, 10:14am UTC](https://forum.inductiveautomation.com/t/snippet-to-decode-base64-uuids-in-proj-files/17046/1 "2018-02-20T10:14:15Z")

</div>

In case anyone else finds this useful…

In .proj export files, resources are linked to folders by UUID - but the folder UUID is encoded differently, which makes it hard to match them up:

```auto
<resource id='20439' name='Folder A' module='fpmi' modver='' type='__folder' ver='0' dirty='false' editcount='0' parent='' oemlocked='false' scope='4' protected='false'>
    <doc></doc>
    <bytes><![CDATA[gfVM03u8cpUxQaQOH3JN0Q==]]></bytes>
</resource>
<resource id='20414' name='Folder B' module='fpmi' modver='' type='__folder' ver='0' dirty='false' editcount='0' parent='d14d721f-0ea4-4131-9572-bc7bd34cf581' oemlocked='false' scope='4' protected='false'>
    <doc></doc>
    <bytes><![CDATA[UPki+Fgp2qSCSLoUCA8ktw==]]></bytes>
</resource>

```

Strangely, the base64 encoded version is also reversed from the UUID string.

You can convert between the UUID string and the base64 representation with the following:

```auto
#!/usr/bin/env python
import uuid
from base64 import b64encode, b64decode

def encode(text):
    return b64encode(uuid.UUID(text).bytes[::-1])

def decode(text):
    return uuid.UUID(bytes=b64decode(text)[::-1])

if __name__ == ' __main__':
    import sys
    for arg in sys.argv[1:]:
        if len(arg) == 24:
            print decode(arg)
        elif len(arg) == 36:
            print encode(arg)
        else:
            sys.stderr.write('Invalid length\n')
            sys.exit(1)

```

Example usage:

```auto
$ ./uuid_convert.py d14d721f-0ea4-4131-9572-bc7bd34cf581
gfVM03u8cpUxQaQOH3JN0Q==
$ ./uuid_convert.py gfVM03u8cpUxQaQOH3JN0Q==
d14d721f-0ea4-4131-9572-bc7bd34cf581

```
