第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

go - 如何在go中將字符串加密為ASCII裝甲文件

go - 如何在go中將字符串加密為ASCII裝甲文件

Go
慕尼黑8549860 2022-01-10 11:00:34
我現(xiàn)在真的很難在我的代碼中找到錯(cuò)誤——任務(wù)是將一個(gè)字符串加密到一個(gè) pgp ASCII 裝甲文件中——這是一件簡(jiǎn)單的事情。受此要點(diǎn)啟發(fā),我使用以下函數(shù):// pgp encryption using the pgp RSA certificate// massive thx to https://gist.github.com/jyap808/8250124func encToFile(secretString string, filename string) (string, error) {  log.Println("Public Keyring: ", publicKeyring)  encryptionType := "PGP MESSAGE"  // Read in public key  keyringFileBuffer, _ := os.Open(publicKeyring)  defer keyringFileBuffer.Close()   entityList, err := openpgp.ReadArmoredKeyRing(keyringFileBuffer)   check(err)  encbuf := bytes.NewBuffer(nil)  w, err := armor.Encode(encbuf, encryptionType, nil) // the encoder somehow makes this into ASCII armor  check(err)  plaintext, err := openpgp.Encrypt(w, entityList, nil, nil, nil)  check(err)  message := []byte(secretString)  _, err = plaintext.Write(message)  plaintext.Close()  w.Close()  // Output encrypted/encoded string  log.Println("Writing Encrypted Secred to: ", filename)  // we write the file into a file  err = ioutil.WriteFile(filename, encbuf.Bytes(), 0644)  check(err)  log.Println("File:\n", encbuf.String())  return encbuf.String(), nil}但是,另一端的人收到此錯(cuò)誤消息:gpg: encrypted with RSA key, ID 5BE299DCgpg: decryption failed: No secret key非常歡迎提示和建議!
查看完整描述

1 回答

?
阿晨1998

TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊

但是,另一端的人收到此錯(cuò)誤消息:

gpg: encrypted with RSA key, ID 5BE299DC
gpg: decryption failed: No secret key

如果您為正確的密鑰加密,我認(rèn)為您沒(méi)有做錯(cuò)任何事情。查看密鑰服務(wù)器上的該密鑰,您已加密為最新的(也是唯一的)加密子密鑰。

如果“另一端的人”收到一條錯(cuò)誤消息,表明他不會(huì)持有密鑰,那么要么

  • 您使用錯(cuò)誤的密鑰進(jìn)行加密,

  • “另一個(gè)人”給了你錯(cuò)誤的鑰匙或

  • “另一個(gè)人”把自己搞砸了。

您可以通過(guò)將加密的內(nèi)容傳遞給gpg --list-packetsor來(lái)驗(yàn)證出了什么問(wèn)題pgpdump,它列出了消息中包含的 OpenPGP 數(shù)據(jù)包,并且對(duì)于調(diào)試 OpenPGP 問(wèn)題非常有幫助。


查看完整回答
反對(duì) 回復(fù) 2022-01-10
  • 1 回答
  • 0 關(guān)注
  • 180 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)