kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

php AES、DES java

一、AES

java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
byte[] tmp = asBin(encrypted);
byte[] key = asBin(sKey);

SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(2, skeySpec);
byte[] decrypted = cipher.doFinal(tmp);
return new String(decrypted);


private static byte[] asBin(String src) {
	byte[] encrypted = new byte[src.length() / 2];
	for (int i = 0; i < src.length() / 2; i++) {
		int high = Integer.parseInt(src.substring(i * 2, i * 2 + 1), 16);
		int low = Integer.parseInt(src.substring(i * 2 + 1, i * 2 + 2), 16);
		encrypted[i] = (byte)(high * 16 + low);
	}
	return encrypted;
}

php

1
2
3
$d1 = hex2bin($src);
$d2 = hex2bin($key);
$out0 = openssl_decrypt($d1, 'aes-128-ecb', $d2, OPENSSL_RAW_DATA);

二、DES

1
2
3
4
5
6
7
8
9
10
  public static byte[] decrypt1(byte[] msg, String key) throws Exception {
    Security.addProvider(new SunJCE());
    byte[] keyBytes = genKey(key);
    SecretKey deskey = new SecretKeySpec(keyBytes, "DESede");
    IvParameterSpec ivspec = genIV();
    byte[] src = msg;
    Cipher c1 = Cipher.getInstance("DESede/CBC/NoPadding");
    c1.init(2, deskey, ivspec);
    return c1.doFinal(src);
  }

php

1
$out0 = openssl_decrypt($d1, 'DES-EDE3-CBC', $d2, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING);

phpgd 透明背景

可以露出底层内容

1
2
3
4
5
6
7
8
9
$image = imagecreatetruecolor($image_width, $image_height);
$bg_color = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $bg_color);
imagealphablending($image, false);
imagesavealpha($image, true);

$font_color = imagecolorallocate($image, 0, 0, 0);

imagettftext($image, $font_size, 0, 3, 27, $font_color, $font, $text);

MAC地址表项的老化时间及老化机制

https://support.huawei.com/enterprise/zh/doc/EDOC1100277049/e5f2249c

MAC地址表项的老化时间默认5分钟,命令mac-address aging-time可以修改MAC地址的老化时间。

MAC地址的老化时间更新机制:某条数据流进入端口后,MAC地址进行动态学习。如果该数据流一直存在,则此MAC地址老化时间会一直刷新,不会进行老化。当数据流停止,MAC地址经过老化时间后自动老化。