key using Key.get_or_insert in google app

Hi everyone I'm beginner CTF player and I have same lake with python modules and I face following problem

i dump the file container the flag but it use python to generate it as a hash using this key

can same one help me to understand this code

  key = Key.get_or_insert("key", namespace="default").secret.encode("utf-8")

and secret = ndb.StringProperty()

1 answer

  • answered 2017-06-17 19:32 Linch

    logic has not changed, but so the code is easier to comment on

    key = Key.get_or_insert('key', namespace='default') # if object exists retrieve it, otherwise create and retrieve it 
    secret = key.secret # get value of secret field
    secret.encode('utf-8') # return an encoded version of the string as a bytes object.