- #gem install fast-aes
- require 'rubygems'
- require 'fast-aes'
- # key can be 128, 192, or 256 bits
- key = '42#3b%c$dxyT,7a5=+5fUI3fa7352&^:'
- aes = FastAES.new(key)
- text = "Hey there, how are you?"
- data = aes.encrypt(text)
- puts aes.decrypt(data) # "Hey there, how are you?"
- # 这个库是用c写的,所以速度很快.
- # <a href="https://github.com/nateware/fast-aes">https://github.com/nateware/fast-aes
- #该片段来自于http://www.codesnippet.cn/detail/030420132715.html
来源: http://www.codesnippet.cn/detail/030420132715.html