小编Fla*_*Man的帖子

使用初始化向量和填充正确执行AES 128加密

我使用初始化矢量和填充来实现AES 128位加密,如下面的代码所示。我碰巧正在使用ColdFusion,但我认为这并不重要。加密的结果显示了一些重复的模式,这是我本来不会想到的,但是再次,我不知道为此正确输出的特征。我是否正在正确执行初始化向量和填充?

<!---
To encrypt this, for example:
    "String1"
Prefix the string with an Initialization Vector of 16 random characters,
plus enough padding ("000000001") to make the entire string a multiple of 16 characters (32 characters, here)
    "HoMoz4yT0+WAU7CX000000001String1"
Now encrypt the string to this (64 characters):
    "Bn0k3q9aGJt91nWNA0xun6va8t8+OiJVmCqv0RzUzPWFyT4jUMzZ56pG5uFt6bGG"
--->

<cfoutput>

    <cfset EncryptKey="LpEecqQe3OderPakcZeMcw==">

    <cfloop index="StringToEncrypt" list="String1,String2,String3,String3">
        <!--- Make random Initialization Vector (IV) of length 16 
        (create it from GenerateSecretKey(), but GenerateSecretKey is NOT the key that we encrypt/decrypt with) --->
        <cfset IV=left(GenerateSecretKey("AES",128),16)> …
Run Code Online (Sandbox Code Playgroud)

encryption coldfusion aes

5
推荐指数
1
解决办法
161
查看次数

标签 统计

aes ×1

coldfusion ×1

encryption ×1