// Copyright 2019 The Go 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 obscuretestdata contains functionality used by tests to more easily // work with testdata that must be obscured primarily due to // golang.org/issue/34986.
package obscuretestdata import ( ) // Rot13 returns the rot13 encoding or decoding of its input. func ( []byte) []byte { := make([]byte, len()) copy(, ) for , := range { switch { case 'A' <= && <= 'M' || 'a' <= && <= 'm': [] = + 13 case 'N' <= && <= 'Z' || 'n' <= && <= 'z': [] = - 13 } } return } // DecodeToTempFile decodes the named file to a temporary location. // If successful, it returns the path of the decoded file. // The caller is responsible for ensuring that the temporary file is removed. func ( string) ( string, error) { , := os.Open() if != nil { return "", } defer .Close() , := os.CreateTemp("", "obscuretestdata-decoded-") if != nil { return "", } if , := io.Copy(, base64.NewDecoder(base64.StdEncoding, )); != nil { .Close() os.Remove(.Name()) return "", } if := .Close(); != nil { os.Remove(.Name()) return "", } return .Name(), nil } // ReadFile reads the named file and returns its decoded contents. func ( string) ([]byte, error) { , := os.Open() if != nil { return nil, } defer .Close() return io.ReadAll(base64.NewDecoder(base64.StdEncoding, )) }