2023年11月15日 星期三

Excel 敏感資料遮蔽處理

參考資料:[Excel] 個資隱碼篇-例身分證G123***456

有時候Excel中有些欄位資料是很敏感的,例如姓名、身分證字號、電話、信箱等,遇到這些欄位我們就必須作敏感資料的遮蔽處理。

1-1. 身分證字號,從第幾碼之後將敏感資料用*號替代

=REPLACE(A2,D2,(LEN(A2)-D2)+1,REPT("*",(LEN(A2)-D2)+1))


1-2.信箱,從第幾碼之後將敏感資料用*號替代,但只保留@之後的資訊

=REPLACE(A5,D5,(FIND("@",A5)-D5),REPT("*",(FIND("@",A5)-D5)))


畫面如下



2023年7月19日 星期三

MS SQL 計算字串中的全形、半形,各佔幾個字

計算字串中的全形、半形,各佔幾個字。

DECLARE @MSG nvarchar(500),@OrderNo int,@x1 int,@s1 int;

--假設@MSG為要計算的字串內容
Set @MSG=N'零壹貳參肆伍陸柒捌玖拾零壹貳參肆伍陸柒捌玖拾零壹貳參肆伍陸柒捌玖拾零壹貳參肆伍陸柒捌玖拾零壹貳參肆伍陸柒捌玖拾零壹貳參肆伍陸柒捌玖ab,cdA。';

Set @x1=LEN(@MSG);
Set @s1=1;

DECLARE @fullWidthCount INT,@halfWidthCount INT;
Set @fullWidthCount=0;
Set @halfWidthCount=0;

WHILE (@s1<=@x1)
BEGIN
IF (UNICODE(SUBSTRING(@MSG, @s1, 1)) > 255)
Begin
Set @fullWidthCount=@fullWidthCount+1;
End
ELSE
Begin
Set @halfWidthCount=@halfWidthCount+1;
End
--加1
Set @s1=@s1+1
END

print DATALENGTH(@MSG);
print LEN(@MSG);
print 'fullWidthCount='+Convert(varchar,@fullWidthCount)+';halfWidthCount='+Convert(varchar,@halfWidthCount);

2023年6月20日 星期二

Windows 修改Apache port,瀏覽器強制導回localhost

本篇記錄當我修改完Apache port後,在瀏覽器的網址列輸入localhost:8081,瀏覽器就會自動強制導回localhost。

參考資料:Apache Virtual Host 多網域網站放置在同一台主機

2023/06/20 

一般修改Apache Port只需要修改httpd.conf檔即可,檔案的位置位在apache/conf目錄底下,並找到以下兩行代碼,如下。

Listen 80
.....
ServerName localhost:80

將上方的80 Port改為你想要的Port即可,我是將80改為8081,改完後請重新啟動Apache。

重點來了,當我重啟Apache後,只要我在瀏覽器的網址列輸入localhost:8081(預設的80是我本機的IIS),瀏覽器就會自動強制導回localhost(也就是IIS),因為我公司專案是委外開發的,後來我在httpd.conf看到了這一行代碼,如下。

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

原來我的專案中是有設定了Virtual hosts,其目的是為了可以在同一個伺服器架設多個網站。

於是我試著修改conf/extra/httpd-vhosts.conf檔,將原本有80的地方改為8081,如下。

<VirtualHost _default_:8081>
DocumentRoot "${WEBROOT}"
<Directory "${WEBROOT}">
Options FollowSymLinks
AllowOverride All
Require all granted
AddDefaultCharset utf-8
</Directory>
</VirtualHost>

修改完後一樣重新啟動Apache,就可以正常執行localhost:8081