xipher
v1.8.0
Xipher是一組策劃的加密原語集合,以執行基於密鑰/密碼的非對稱加密。
從“發行版”頁面下載最新的二進製文件,然後將其添加到您的路徑中。
Xipher可以使用MacOS上的以下命令與Brew一起安裝
brew install shibme/tap/xipher使用Shell(MacOS/Linux):
curl -fsSL https://dev.shib.me/xipher/install/install.sh | sh使用PowerShell(Windows):
irm https: // dev.shib.me / xipher / install / install.ps1 | iex使用Shell(MacOS/Linux):
curl -fsSL https://dev.shib.me/xipher/install/install.sh | sh -s v1.1.0使用PowerShell(Windows):
$v = " 1.1.0 " ; irm https: // dev.shib.me / xipher / install / install.ps1 | iex您也可以在不使用Docker安裝的情況下運行Xipher:
docker run --rm -v $PWD :/data -it shibme/xipher help 使用Web組件實施的與CLI互動的Web接口可在此處使用。
以下序列圖說明了Web應用程序的工作流程。
測序圖
參與者RX為Xipher <br>(在瀏覽器上)
演員接收者
演員發送者
參與者SX作為Xipher <br>(在瀏覽器上)
接收器 - >>+rx:在瀏覽器上打開Xipher應用程序
RX- >> RX:生成一個鍵對,並將它們存儲在瀏覽器本地存儲中
RX - >> - 接收器:返回公共密鑰<br>(作為可以共享的URL)
接收器 - >>+發件人:共享加密URL <br>(這包含公共密鑰作為參數)
發件人 - >>+sx:打開公共加密URL <br>(打開Xipher加密網頁)
發件人 - >> SX:輸入需要加密的數據
SX- >> SX:使用URL的公共密鑰對數據進行加密
SX - >> - 發件人:返回使用公共密鑰加密的Ciphertext
發件人 - >> - 接收器:將加密的密文發送到接收者
接收器 - >>+rx:輸入Ciphertext <br>(在“ 9月”頁面中)
rx- >> rx:解密密文<br>(使用本地存儲中的秘密鍵)
RX - >> - 接收器:返回解密數據
安裝軟件包
go get -u dev.shib.me/xipher在您的代碼中使用它
package main
import (
"encoding/base32"
"fmt"
"dev.shib.me/xipher"
)
func main () {
// Creating a new secret key for password
scrtKey , err := xipher . NewSecretKeyForPassword ([] byte ( "Paws0meKittyKuwan!" ))
if err != nil {
panic ( err )
}
// Deriving public key from secret key
pubKey , err := scrtKey . PublicKey ( false )
if err != nil {
panic ( err )
}
publicKeyBytes , err := pubKey . Bytes ()
if err != nil {
panic ( err )
}
fmt . Println ( "PublicKey:" , base32 . StdEncoding . WithPadding ( base32 . NoPadding ). EncodeToString ( publicKeyBytes ))
platinText := [] byte ( "Hello World!" )
// Encrypting plain text with public key
cipherText , err := pubKey . Encrypt ( platinText , true )
if err != nil {
panic ( err )
}
fmt . Println ( "Encrypted:" , base32 . StdEncoding . WithPadding ( base32 . NoPadding ). EncodeToString ( cipherText ))
// Decrypting cipher text with secret key
plainText , err := scrtKey . Decrypt ( cipherText )
if err != nil {
panic ( err )
}
fmt . Println ( "Decrypted:" , string ( plainText ))
}要在瀏覽器應用中使用Xipher作為Web組件(WASM)模塊,請按照以下示例。
< html >
< head >
< meta charset =" utf-8 " />
< script src =" https://dev.shib.me/xipher/wasm/wasm_exec.js " > </ script >
< script >
const go = new Go ( ) ;
WebAssembly . instantiateStreaming ( fetch ( "https://dev.shib.me/xipher/wasm/xipher.wasm" ) , go . importObject ) . then ( ( result ) => {
go . run ( result . instance ) ;
} ) ;
</ script >
</ head >
< body >
Call wasm methods that begin with xipher. For example: xipherNewSecretKey()
</ body >
</ html > Xipher使用以下算法和庫來實現其功能:
以下序列圖說明了使用基於密碼的公共密鑰加密數據中Xipher的工作流程。
測序圖
參與者RX作為Xipher
演員接收者
演員發送者
參與者SX作為Xipher
接收器 - >>+rx:派生公共(輸入密碼)
RX - >> - 接收器:返回公鑰
接收器 - >>發件人:共享公鑰
發件人 - >>+SX:使用公鑰加密數據
SX - >> - 發件人:返回使用公共密鑰加密的密文
發件人 - >>接收器:將加密的密文發送到接收者
接收器 - >>+rx:解密數據(輸入密文和密碼)
RX - >> - 接收器:返回解密數據
提供此工具/庫無需任何保證,也不能保證其穩定性。由於其某些組件的實驗性質,預計將來將對代碼,存儲庫和API進行修改。在將其納入生產應用程序中之前,請謹慎行事。請立即報告任何已確定的安全問題。高度讚賞您在通知我們這類問題方面的合作。