Medning wrong commit

This commit is contained in:
Jakub Lehotsky 2018-11-22 00:01:18 +01:00
parent 8cf5054ff2
commit 686d4f1b7d

View file

@ -214,36 +214,6 @@ func (pm *PmCrypto) EncryptMessage(plainText string, publicKey *KeyRing, private
return outBuf.String(), nil return outBuf.String(), nil
} }
//EncryptMessageWithPassword encrypt a plain text to pgp message with a password
//plainText string: clear text
//output string: armored pgp message
func (pm *PmCrypto) EncryptMessageWithPassword(plainText string, password string) (string, error) {
var outBuf bytes.Buffer
w, err := armor.Encode(&outBuf, armorUtils.MESSAGE_HEADER, internal.ArmorHeaders)
if err != nil {
return "", err
}
config := &packet.Config{Time: pm.getTimeGenerator()}
plaintext, err := openpgp.SymmetricallyEncrypt(w, []byte(password), nil, config)
if err != nil {
return "", err
}
message := []byte(plainText)
_, err = plaintext.Write(message)
if err != nil {
return "", err
}
err = plaintext.Close()
if err != nil {
return "", err
}
w.Close()
return outBuf.String(), nil
}
//DecryptMessageWithPassword decrypt a pgp message with a password //DecryptMessageWithPassword decrypt a pgp message with a password
//encrypted string : armored pgp message //encrypted string : armored pgp message
//output string : clear text //output string : clear text