Skip to content

It seems decrytion cannot deal with encrypted empty string #150

@johnnyp1883

Description

@johnnyp1883

Hi I found the decryption cannot handle the empty string
It returns error "invalid length of message"
Is it possible to allow empty string in the future?

func TestEncryptAndDecrypt(t *testing.T) {
	privkey, err :=  GenerateKey()
	if !assert.NoError(t, err) {
		return
	}

	testingEmptyStringMessage := ""
	ciphertext, err := Encrypt(privkey.PublicKey, []byte(testingEmptyStringMessage))
	if !assert.NoError(t, err) {
		return
	}

	plaintext, err := Decrypt(privkey, ciphertext)
	if !assert.NoError(t, err) {
		return
	}

	assert.Equal(t, testingMessage, string(plaintext))
}
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions