blob: c278e397813191778cd5c0828657ffe6f9699156 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pathperms
import (
// ComputeVersion produces the tag value returned by access.GetPermissions()
// (per v23/services/permissions/service.vdl) that GetPermissions/SetPermissions
// use to determine if the Permissions have been asynchronously modified.
func ComputeVersion(perms access.Permissions) (string, error) {
b := new(bytes.Buffer)
if err := access.WritePermissions(b, perms); err != nil {
return "", err
md5hash := md5.Sum(b.Bytes())
version := hex.EncodeToString(md5hash[:])
return version, nil