liujie
2026-08-11 323764c813a09cd56cdab780155ef659dbe0b364
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.ruoyi.system.utils;
 
public class DoorDeviceCredentialCryptoTest
{
    public static void main(String[] args)
    {
        System.setProperty("door.device.credential.key", "test-door-device-credential-key-32chars");
        try
        {
            String cipherText = DoorDeviceCredentialCrypto.encrypt("device-password");
            if (cipherText.contains("device-password"))
            {
                throw new AssertionError("密文不应包含明文密码");
            }
            if (!"device-password".equals(DoorDeviceCredentialCrypto.decrypt(cipherText)))
            {
                throw new AssertionError("设备密码加解密结果不一致");
            }
        }
        finally
        {
            System.clearProperty("door.device.credential.key");
        }
    }
}