Browse Source

crypto/armor: remove unused package (#6963)

pull/6970/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
87b876a73b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 59 deletions
  1. +4
    -0
      CHANGELOG_PENDING.md
  2. +0
    -39
      crypto/armor/armor.go
  3. +0
    -20
      crypto/armor/armor_test.go

+ 4
- 0
CHANGELOG_PENDING.md View File

@ -16,6 +16,10 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi
- Go API - Go API
- [crypto/armor]: \#6963 remove package which is unused, and based on
deprecated fundamentals. Downstream users should maintain this
library. (@tychoish)
- Blockchain Protocol - Blockchain Protocol
### FEATURES ### FEATURES


+ 0
- 39
crypto/armor/armor.go View File

@ -1,39 +0,0 @@
package armor
import (
"bytes"
"fmt"
"io/ioutil"
"golang.org/x/crypto/openpgp/armor"
)
func EncodeArmor(blockType string, headers map[string]string, data []byte) string {
buf := new(bytes.Buffer)
w, err := armor.Encode(buf, blockType, headers)
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %s", err))
}
_, err = w.Write(data)
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %s", err))
}
err = w.Close()
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %s", err))
}
return buf.String()
}
func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error) {
buf := bytes.NewBufferString(armorStr)
block, err := armor.Decode(buf)
if err != nil {
return "", nil, nil, err
}
data, err = ioutil.ReadAll(block.Body)
if err != nil {
return "", nil, nil, err
}
return block.Type, block.Header, data, nil
}

+ 0
- 20
crypto/armor/armor_test.go View File

@ -1,20 +0,0 @@
package armor
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestArmor(t *testing.T) {
blockType := "MINT TEST"
data := []byte("somedata")
armorStr := EncodeArmor(blockType, nil, data)
// Decode armorStr and test for equivalence.
blockType2, _, data2, err := DecodeArmor(armorStr)
require.Nil(t, err, "%+v", err)
assert.Equal(t, blockType, blockType2)
assert.Equal(t, data, data2)
}

Loading…
Cancel
Save