Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for CreateRandBytes (0.25 sec)

  1. cmd/kubeadm/app/util/crypto/crypto.go

    limitations under the License.
    */
    
    package crypto
    
    import (
    	"crypto/aes"
    	"crypto/cipher"
    	"crypto/rand"
    
    	"github.com/pkg/errors"
    )
    
    // CreateRandBytes returns a cryptographically secure slice of random bytes with a given size
    func CreateRandBytes(size uint32) ([]byte, error) {
    	bytes := make([]byte, size)
    	if _, err := rand.Read(bytes); err != nil {
    		return nil, err
    	}
    	return bytes, nil
    }
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Sun Jul 04 08:41:27 UTC 2021
    - 2.1K bytes
    - Viewed (0)
  2. cmd/kubeadm/app/util/crypto/crypto_test.go

    	kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
    )
    
    func TestEncryptAndDecryptData(t *testing.T) {
    	key1, err := CreateRandBytes(kubeadmconstants.CertificateKeySize)
    	if err != nil {
    		t.Fatal(err)
    	}
    	key2, err := CreateRandBytes(kubeadmconstants.CertificateKeySize)
    	if err != nil {
    		t.Fatal(err)
    	}
    	testData := []byte("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue Aug 17 14:40:46 UTC 2021
    - 2.4K bytes
    - Viewed (0)
  3. cmd/kubeadm/app/phases/copycerts/copycerts.go

    	}
    	return tokens[0].Token.ID, nil
    }
    
    // CreateCertificateKey returns a cryptographically secure random key
    func CreateCertificateKey() (string, error) {
    	randBytes, err := cryptoutil.CreateRandBytes(kubeadmconstants.CertificateKeySize)
    	if err != nil {
    		return "", err
    	}
    	return hex.EncodeToString(randBytes), nil
    }
    
    // UploadCerts save certs needs to join a new control-plane on kubeadm-certs sercret.
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Sun Jan 01 00:15:30 UTC 2023
    - 10.2K bytes
    - Viewed (0)
Back to top