Skip to content

Crypto - 加密解密

Crypto 提供加密解密功能。

特性

  • 对称加密(AES)
  • 非对称加密(RSA)
  • 哈希(MD5、SHA256)
  • 签名和验证

安装

bash
go get github.com/o-zoox/crypto

快速开始

基本使用

go
package main

import (
    "fmt"
    "github.com/o-zoox/crypto"
)

func main() {
    // AES 加密
    key := []byte("1234567890123456")
    plaintext := "Hello, World!"
    
    encrypted, err := crypto.AESEncrypt(plaintext, key)
    if err != nil {
        panic(err)
    }
    
    // AES 解密
    decrypted, err := crypto.AESDecrypt(encrypted, key)
    if err != nil {
        panic(err)
    }
    
    fmt.Println("Decrypted:", decrypted)
    
    // SHA256 哈希
    hash := crypto.SHA256(plaintext)
    fmt.Println("Hash:", hash)
}

更多信息

基于 VitePress 构建