1
0
mirror of https://github.com/ssh-vault/ssh-vault.git synced 2025-07-29 18:01:12 +03:00

encode method to add line break every 64 chars

This commit is contained in:
nbari
2016-10-20 22:39:16 +02:00
parent 1dc11bd0da
commit c83e4cf193
3 changed files with 52 additions and 13 deletions

16
encode.go Normal file
View File

@ -0,0 +1,16 @@
package sshvault
import "bytes"
// Encode return base64 string with line break every 64 chars
func (v *vault) Encode(b string, n int) []byte {
a := []rune(b)
var buffer bytes.Buffer
for i, r := range a {
buffer.WriteRune(r)
if i > 0 && (i+1)%64 == 0 {
buffer.WriteRune('\n')
}
}
return buffer.Bytes()
}