package pgpcrypt import ( "bytes" "testing" ) var privKey = `-----BEGIN PGP PRIVATE KEY BLOCK----- Version: Keybase OpenPGP v1.0.0 Comment: https://keybase.io/crypto xcFGBFqmSykBBADMW3p3YOiY4b1zi5C/tAYEF1iy55brS119LT0odc43XCTtPtG5 X9SzcSNrM/1azGHpLmgtjSbw8K9/GfS27E5MKGd4/9frpSAMdFutSmMEf+p/3vlb xIbpI0PP0UdjIki3kK2+1W82Ca7JnnCOtP7o+01Q5pKmIfte+s0/Eg87mwARAQAB /gkDCC7DXsV1FnCZYMxEN+8nT6bSTqEXpwOLL6Ez9xteoLuY9aZJSrEhXF60pDBe Y75k5yIstXIpwVNaR8HXTLeceeCx1YMBjuSb5vJxKY7Rh4PiYoYPqi6oojS3EvLz 7abk4iDaKigY2NQlNOwvHFTMr+5H9jBW/sBkOY/CDI+Efe+/jGPE8f1QaGO3MIFF yf7fYnyrtYPEJV5SUeGO27qtLSmzuwhrO4545UScOsrOxsV+z5VpN+VmBvooQYdM Vvg26McxEEeXA9kmjLriget5mHWLVFamlOMWjB52C9B27voOp3ivI3PlA4FA2k4i N7meCLSGjsiBwZDDhbAQf0QYy1h9Qu2ddNBKRKy7sQhRov6uEMLlRLg/3V+lJd/M V2ndHsRF+GpOo3RmWxFb32SQb4bhMjl8dvOWW2vTWPqn6PV4HvhdHq+guCWQpSgU cxleZ0RpUEPwbhivm+7uOyLZB5AoCaeh7H56vvH1fUYtTxcMaTNXug7NHFRlc3RV c2VyIDx0ZXN0QGxvY2FsLmRvbWFpbj7CrQQTAQoAFwUCWqZLKQIbLwMLCQcDFQoI Ah4BAheAAAoJEBxI5bOJwbX4rI4D+wak0VJO3oxpVy/T7I3e0vYVuZRTmRwX73/H 7LpMpIIkXMEVeDxdbicHTHrwuT7EHkwTMhPRNgnk4d6TMmKeQ+9OvtrV5j/x0MVD OW9G3Gks7I+7XAjoN/Nw7AV+0qyZhwOw1yxFTCxpkaE0TUBhvq8jsnJVsV162F84 8goFl+a1x8FGBF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vavT6mD8FaPMnNiXVyW264SwtnvTTvJcXQOwh/Bzl sllR5Xi3nPICt/lUUfbXGZ8QpLV1NcQTB1bWD23E9XXfvRZK2hPWI26b5PkkX3bg MwfEz7bN+ypIsO6oX6vthx/pe5Y= =2HiH -----END PGP PRIVATE KEY BLOCK-----` func TestEncrypt(t *testing.T) { keyIO := new(bytes.Buffer) _, err := keyIO.Write([]byte(privKey)) if err != nil { t.Error(err) } srcIO := new(bytes.Buffer) _, err = srcIO.Write([]byte("test msg")) if err != nil { t.Error(err) } dstIO := new(bytes.Buffer) err = Encrypt2(keyIO, srcIO, dstIO) if err != nil { t.Error(err) } } func TestDecrypt(t *testing.T) { keyIO := new(bytes.Buffer) _, err := keyIO.Write([]byte(privKey)) if err != nil { t.Error(err) } srcIO := new(bytes.Buffer) _, err = srcIO.Write([]byte("test msg")) if err != nil { t.Error(err) } encIO := new(bytes.Buffer) err = Encrypt2(keyIO, srcIO, encIO) if err != nil { t.Error(err) } keyIO2 := new(bytes.Buffer) _, err = keyIO2.Write([]byte(privKey)) if err != nil { t.Error(err) } decIO := new(bytes.Buffer) err = Decrypt2(keyIO2, encIO, decIO, "12345") if err != nil { t.Error(err) } }