The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
body007

EncryptionFile 发布 v1.0.7 版本,支持标准库 cipher 的全部 3 中加密算法接口

  •  
  •   body007 · Sep 8, 2023 · 991 views
    This topic created in 976 days ago, the information mentioned may be changed or developed.

    项目地址: https://github.com/jan-bar/EncryptionFile

    之所以更新这一版,是因为有人觉得上个版本中只用到aes cfb这种流式加密算法不安全,他们希望用更安全的aes gcm加密方式。因此我看了 go 标准库支持cipher.AEAD ,cipher.Stream ,cipher.BlockMode这三种加密接口,因此这一版本直接支持这三种接口。用户还可以自定义加解密方案,只要是上面三种接口类型就可以实现数据安全加解密。

    你也可以用我内置的 EncryptionFile.GenEncCipher ,EncryptionFile.GenDecCipher 这两个方法轻松实现指定加密算法,如下所示。

    当然你也可以自己写方法,只要实现cipher.AEAD ,cipher.Stream ,cipher.BlockMode这三种接口就行。

    // an encryption scheme can be specified with the built-in method
    // GenEncCipher(cipher.NewCFBEncrypter)
    // GenEncCipher(cipher.NewCTR)
    // GenEncCipher(cipher.NewOFB)
    // GenEncCipher(cipher.NewCBCEncrypter)
    // GenEncCipher(cipher.NewGCM)
    EncData(Reader, Writer, pubKey, md5.New(), GenEncCipher(cipher.NewCFBEncrypter))
    
    // an decryption scheme can be specified with the built-in method
    // GenDecCipher(cipher.NewCFBDecrypter)
    // GenDecCipher(cipher.NewCTR)
    // GenDecCipher(cipher.NewOFB)
    // GenDecCipher(cipher.NewCBCDecrypter)
    // GenDecCipher(cipher.NewGCM)
    DecData(Reader, Writer, priKey, md5.New(), GenDecCipher(cipher.NewCFBDecrypter))
    

    可用学习单元测试 TestCipher,掌握这个库的用法。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5684 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 07:01 · PVG 15:01 · LAX 00:01 · JFK 03:01
    ♥ Do have faith in what you're doing.