`
acme_ltt
  • 浏览: 52467 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Erlang实现加密解密

阅读更多

    各种加密、解密的原理,我就不在这赘述了,在Erlang 的官网上,提供了crypto module,其中包含了常见的md5加密,AES加密,RSA加密,详见: http://www.erlang.org/doc/man/crypto.html

 

    在AES的CBC加密、解密模式中,包括三个参数:

1、Key,这是AES加密的密钥,可为iolist类型,也可为binary类型,长度必须为128位,也就是16个字节;

2、IVec,初始向量,类型为binary,长度必须为128位,16个字节;

3、Text,待加密的数据,类型可为iolist也可为binary,但是,长度也必须是128位;

    aes_cbc_128_encrypt(Key, IVec, Text) -> Cipher

Types:

Key = Text = iolist() | binary()
IVec = Cipher = binary()
Encrypts Text according to AES in Cipher Feedback mode (CFB) or Cipher Block Chaining mode (CBC).
 Text must be a multiple of 128 bits (16 bytes). Key is the AES key, and IVec is an arbitrary initializing
 vector. The lengths of Key and IVec must be 128 bits (16 bytes).

    由以上参数,可以说明:AES的CBC加密、解密适合特定长度的数据。

 

 

    具体内容详见erlang.org

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics