org.plasmalabs.sdk.syntax.GroupPolicySyntax.scala Maven / Gradle / Ivy
The newest version!
package org.plasmalabs.sdk.syntax
import org.plasmalabs.sdk.common.ContainsImmutable.ContainsImmutableTOps
import org.plasmalabs.sdk.common.ContainsImmutable.instances.groupPolicyImmutable
import org.plasmalabs.sdk.models.GroupPolicy
import org.plasmalabs.sdk.models.GroupId
import com.google.protobuf.ByteString
import java.security.MessageDigest
import scala.language.implicitConversions
trait GroupPolicySyntax {
implicit def groupPolicyAsGroupPolicySyntaxOps(groupPolicy: GroupPolicy): GroupPolicyAsGroupPolicySyntaxOps =
new GroupPolicyAsGroupPolicySyntaxOps(groupPolicy)
}
class GroupPolicyAsGroupPolicySyntaxOps(val groupPolicy: GroupPolicy) extends AnyVal {
def computeId: GroupId = {
val digest: Array[Byte] = groupPolicy.immutable.value.toByteArray
val sha256 = MessageDigest.getInstance("SHA-256").digest(digest)
GroupId(ByteString.copyFrom(sha256))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy