srv
srv

Reputation: 440

Objectify Web Safe Key Usage

I am using Objectify to store and retrieve data from App Engine Datastore.

String version of the key is created from the datastore object id.

public String getWebsafeKey() {
    return Key.create(UserData.class, id).getString();
}

The websafeKey is used to get the UserData object from the Datastore.

Key<UserData> userDataKey = Key.create(websafeKey);
UserData userData = ofy().load().key(userDataKey).now();

In our Unit testing when the websafeKey is changed a bit, the user data class can still be retrieved.

Passed websafeKey - agxqfmMyaHF1YWxpdHlyEgsSBU1vdmllGICAgJDSioELDC

Actual websafeKey - agxqfmMyaHF1YWxpdHlyEgsSBU1vdmllGICAgJDSioELDA

Is this a known limitation or this can be addressed?

Upvotes: 0

Views: 189

Answers (1)

Alex
Alex

Reputation: 5276

websafeKey's are base64 encoded strings.

Somehow both

agxqfmMyaHF1YWxpdHlyEgsSBU1vdmllGICAgJDSioELDC & agxqfmMyaHF1YWxpdHlyEgsSBU1vdmllGICAgJDSioELDA decode to j j~c2hqualityr Movie

give it a try https://www.base64decode.org/

Upvotes: 2

Related Questions