New file |
| | |
| | | package com.hdl.sdk.link.core.utils.mqtt; |
| | | |
| | | /** |
| | | * 住宅密钥获取工具类 |
| | | * |
| | | * @author yangtao |
| | | * @date 2021.2.26 |
| | | */ |
| | | public class HouseIdSecretUtil { |
| | | |
| | | public static String getSecret(String homeId) { |
| | | String temp = new StringBuffer().append(homeId).reverse().toString(); |
| | | if (temp.length() > 16) { |
| | | return temp.substring(0, 16); |
| | | } |
| | | //长度不够16位用0补齐 |
| | | for (int i = temp.length(); i < 16; i++) { |
| | | temp += "0"; |
| | | } |
| | | return temp; |
| | | } |
| | | |
| | | public static String getSecret(Long homeId) { |
| | | return getSecret(homeId.toString()); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(getSecret("1363358800782790658")); |
| | | } |
| | | } |