package yu_crypto

func PKCS7Trimming(data []byte) []byte {
	return data[:len(data)-int(data[len(data)-1])]
}

func PKCS7Padding(data []byte, block int) []byte {
	j_pad := byte(block - len(data)%block)
	if j_pad < 1 {
		return data
	}
	j_buf := make([]byte, 0, j_pad)
	for j_i := byte(0); j_i < j_pad; j_i++ {
		j_buf = append(j_buf, j_pad)
	}
	return append(data, j_buf...)
}
