小编ebr*_*bra的帖子

使用AES加密16个字节时,为什么密文长32个字节?

我使用加密AES算法,当我加密16字节(一个块)时,结果是32字节.这个可以吗?

我使用的源代码是:

package net.sf.andhsli.hotspotlogin;

import java.security.SecureRandom;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

/**
 * Usage:
 * <pre>
 * String crypto = SimpleCrypto.encrypt(masterpassword, cleartext)
 * ...
 * String cleartext = SimpleCrypto.decrypt(masterpassword, crypto)
 * </pre>
 * @author ferenc.hechler
 */
public class SimpleCrypto {

    public static String encrypt(String seed, String cleartext) throws Exception {
        byte[] rawKey = getRawKey(seed.getBytes());
        byte[] result = encrypt(rawKey, cleartext.getBytes());
        return toHex(result);
    }

    public static String decrypt(String seed, String encrypted) throws Exception {
        byte[] rawKey = getRawKey(seed.getBytes());
        byte[] …
Run Code Online (Sandbox Code Playgroud)

java encryption aes

12
推荐指数
2
解决办法
3万
查看次数

标签 统计

aes ×1

encryption ×1

java ×1