github.com/hashicorp/vault/sdk@v0.11.0/helper/xor/xor_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package xor
     5  
     6  import (
     7  	"encoding/base64"
     8  	"testing"
     9  )
    10  
    11  const (
    12  	tokenB64    = "ZGE0N2JiODkzYjhkMDYxYw=="
    13  	xorB64      = "iGiQYG9L0nIp+jRL5+Zk2w=="
    14  	expectedB64 = "7AmkVw0p6ksamAwv19BVuA=="
    15  )
    16  
    17  func TestBase64XOR(t *testing.T) {
    18  	ret, err := XORBase64(tokenB64, xorB64)
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	if res := base64.StdEncoding.EncodeToString(ret); res != expectedB64 {
    23  		t.Fatalf("bad: %s", res)
    24  	}
    25  }